:root {
  color-scheme: light;
  --blue: #5f88ff;
  --blue-dark: #3f63d9;
  --teal: #53c2cc;
  --logo-k: #082850;
  --ink: #30374f;
  --muted: #6f7890;
  --line: #dbe5f4;
  --paper: #f6f8ff;
  --white: #ffffff;
  --panel: rgba(255, 255, 255, 0.94);
  --shadow: 0 16px 40px rgba(48, 55, 79, 0.1);
  --radius: 8px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --blue: #76a2ff;
  --blue-dark: #8cb2ff;
  --teal: #5ed7df;
  --logo-k: #dcecff;
  --ink: #eef6ff;
  --muted: #a9b8cf;
  --line: rgba(139, 219, 226, 0.2);
  --paper: #081528;
  --white: #101f34;
  --panel: rgba(13, 29, 49, 0.94);
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 0%, rgba(168, 224, 229, 0.48), transparent 28%),
    radial-gradient(circle at 88% 0%, rgba(95, 136, 255, 0.22), transparent 24%),
    linear-gradient(180deg, #f7fdff, var(--paper));
  font-family: Inter, "Helvetica Neue", Arial, Helvetica, sans-serif;
  line-height: 1.55;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 18% 0%, rgba(83, 194, 204, 0.18), transparent 28%),
    radial-gradient(circle at 88% 0%, rgba(95, 136, 255, 0.16), transparent 24%),
    linear-gradient(180deg, #07111f, var(--paper));
}

button,
input,
select,
textarea {
  max-width: 100%;
  color: inherit;
  font: inherit;
}

button,
select,
input[type="button"],
input[type="submit"] {
  -webkit-appearance: none;
  appearance: none;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.admin-shell {
  width: min(1180px, calc(100% - 36px));
  margin-inline: auto;
}

.admin-app.is-locked {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-screen.is-hidden {
  display: none;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(100%, 420px);
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card img {
  width: 156px;
}

.login-card span {
  width: fit-content;
  padding-left: 12px;
  color: var(--blue-dark);
  border-left: 3px solid var(--teal);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.login-card h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
}

.login-card button {
  min-height: 44px;
  color: var(--white);
  background: var(--logo-k);
  border: 0;
  border-radius: 999px;
  font-weight: 900;
}

.login-card .admin-theme-toggle,
.admin-header nav .admin-theme-toggle {
  min-height: 36px;
  padding: 0 12px;
  color: var(--logo-k);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 900;
}

.login-card .admin-theme-toggle {
  justify-self: end;
  min-height: 32px;
  margin-top: -6px;
}

html[data-theme="dark"] .admin-header {
  background: rgba(8, 18, 32, 0.92);
}

html[data-theme="dark"] .login-card,
html[data-theme="dark"] .content-card,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .list-card,
html[data-theme="dark"] .site-control-panel,
html[data-theme="dark"] .writer-management-panel,
html[data-theme="dark"] .editor-panel,
html[data-theme="dark"] .list-panel,
html[data-theme="dark"] .content-item,
html[data-theme="dark"] .admin-header nav a,
html[data-theme="dark"] .admin-header nav button,
html[data-theme="dark"] .import-button,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}

html[data-theme="dark"] .admin-header nav button,
html[data-theme="dark"] .actions button:first-child,
html[data-theme="dark"] .list-tools button.active,
html[data-theme="dark"] .item-actions button:first-child {
  color: #ffffff;
  background: linear-gradient(135deg, #10365d, #1f6fa6);
  border-color: rgba(139, 219, 226, 0.28);
}

html[data-theme="dark"] .login-card .admin-theme-toggle,
html[data-theme="dark"] .admin-header nav .admin-theme-toggle,
html[data-theme="dark"] .actions button,
html[data-theme="dark"] .list-tools button,
html[data-theme="dark"] #reset-form,
html[data-theme="dark"] #duplicate-item,
html[data-theme="dark"] .item-actions button {
  color: var(--ink);
  background: rgba(8, 18, 32, 0.72);
  border-color: var(--line);
}

html[data-theme="dark"] label,
html[data-theme="dark"] .content-item p,
html[data-theme="dark"] .empty-state {
  color: var(--muted);
}

html[data-theme="dark"] .login-card span,
html[data-theme="dark"] .panel-title span,
html[data-theme="dark"] .item-meta span {
  color: var(--teal);
}

html[data-theme="dark"] .item-meta span {
  background: rgba(83, 194, 204, 0.12);
  border: 1px solid rgba(83, 194, 204, 0.24);
}

html[data-theme="dark"] .login-card p {
  color: #ffb4ab;
}

.login-card p {
  min-height: 20px;
  margin: 0;
  color: #b33535;
  font-size: 13px;
  font-weight: 800;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

@media (hover: none), (pointer: coarse) {
  button,
  .admin-header a,
  .admin-nav a,
  input[type="file"]::file-selector-button {
    min-height: 44px;
  }
}

@supports not (backdrop-filter: blur(1px)) {
  .admin-header {
    background: rgba(255, 255, 255, 0.98);
  }

  html[data-theme="dark"] .admin-header {
    background: rgba(8, 18, 32, 0.98);
  }
}

.header-inner {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
}

.admin-brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  font-weight: 800;
}

.admin-brand img {
  width: 128px;
}

.admin-brand span {
  padding-left: 12px;
  border-left: 3px solid var(--teal);
}

.admin-header nav,
.actions,
.list-tools,
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.admin-header nav a,
.admin-header nav button,
.import-button,
.actions button,
.list-tools button,
#reset-form,
#duplicate-item {
  min-height: 38px;
  padding: 0 12px;
  color: var(--logo-k);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 800;
}

.admin-header nav button,
.actions button:first-child,
.list-tools button.active {
  color: var(--white);
  background: var(--logo-k);
  border-color: var(--logo-k);
}

#import-data {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.panel-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 18px;
  align-items: stretch;
  margin-block: 22px;
  padding: clamp(22px, 3vw, 32px);
  color: var(--white);
  background:
    radial-gradient(circle at 82% 0%, rgba(255, 255, 255, 0.24), transparent 28%),
    linear-gradient(135deg, var(--logo-k), var(--blue-dark) 58%, var(--teal));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-hero span,
.panel-title span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.panel-hero h1,
.panel-title h2 {
  margin: 0;
  line-height: 1.1;
}

.panel-hero h1 {
  max-width: 760px;
  font-size: clamp(30px, 4vw, 48px);
}

.panel-hero p {
  max-width: 720px;
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.78);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.hero-stats article {
  display: grid;
  align-content: end;
  min-height: 136px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
}

.hero-stats strong {
  color: var(--white);
  font-size: 38px;
  line-height: 1;
}

.hero-stats span {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.72);
  text-transform: none;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(360px, 1.18fr);
  gap: 18px;
  align-items: start;
  padding-bottom: 28px;
}

.admin-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 18px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.admin-section-nav button {
  min-height: 40px;
  padding: 0 14px;
  color: var(--logo-k);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 900;
}

.admin-section-nav button:hover,
.admin-section-nav button:focus-visible {
  color: #fff;
  background: var(--logo-k);
}

.sync-status {
  margin-left: auto;
  padding: 8px 12px;
  color: #17653a;
  background: #e9f8ef;
  border: 1px solid #bce7ca;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.sync-status.is-checking { color: #715515; background: #fff8dc; border-color: #efdda0; }
.sync-status.is-error { color: #8b2626; background: #fff0f0; border-color: #efc0c0; }

.admin-image-preview {
  margin: 0;
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.admin-image-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.admin-image-preview figcaption {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

[data-field-group][hidden] { display: none !important; }

html[data-theme="dark"] .admin-section-nav button,
html[data-theme="dark"] .admin-image-preview { color: var(--ink); background: var(--panel); border-color: var(--line); }

@media (max-width: 720px) {
  .sync-status { width: 100%; margin-left: 0; text-align: center; }
}

.site-control-panel,
.writer-management-panel {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(83, 194, 204, 0.08), transparent 42%),
    var(--panel);
  border: 1px solid var(--line);
  border-left: 5px solid var(--teal);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.security-panel {
  border-left-color: #3f63d9;
  background:
    linear-gradient(135deg, rgba(95, 136, 255, 0.1), transparent 48%),
    var(--panel);
}

.writer-management-panel {
  background:
    linear-gradient(135deg, rgba(95, 136, 255, 0.08), transparent 42%),
    var(--panel);
  border-left-color: var(--blue-dark);
}

.writer-admin-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(360px, 1.2fr);
  gap: 18px;
  align-items: start;
}

.site-settings-form {
  display: grid;
  gap: 12px;
}

.editor-panel,
.list-panel {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.editor-panel {
  display: grid;
  gap: 14px;
}

.editor-panel.is-editing {
  border-color: rgba(63, 99, 217, 0.46);
  box-shadow: 0 18px 46px rgba(63, 99, 217, 0.16);
}

.edit-status {
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(83, 194, 204, 0.08);
  border: 1px solid rgba(83, 194, 204, 0.22);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
}

.edit-status.is-editing {
  color: var(--logo-k);
  background: linear-gradient(135deg, rgba(83, 194, 204, 0.2), rgba(95, 136, 255, 0.12));
  border-color: rgba(63, 99, 217, 0.34);
}

.panel-title {
  display: flex;
  gap: 14px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 2px;
}

.panel-title span {
  color: var(--blue-dark);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.file-field {
  padding: 12px;
  background: rgba(83, 194, 204, 0.08);
  border: 1px dashed rgba(63, 99, 217, 0.28);
  border-radius: var(--radius);
}

.file-field input[type="file"] {
  padding: 9px;
  background: var(--white);
  border-style: solid;
}

.file-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-help-text {
  margin: -4px 0 0;
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(95, 136, 255, 0.07);
  border: 1px solid rgba(95, 136, 255, 0.16);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(83, 194, 204, 0.18);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.toggle-row label {
  display: inline-flex;
  grid-template-columns: none;
  gap: 8px;
  align-items: center;
  color: var(--ink);
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
}

.list-panel {
  display: grid;
  gap: 14px;
}

#list-search {
  max-width: 260px;
}

.content-list {
  display: grid;
  gap: 10px;
}

.content-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius);
}

.content-item-main {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.content-item-preview {
  width: 92px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.writer-item-main {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.writer-item-main img {
  width: 72px;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
}

.content-item h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.content-item p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 8px;
}

.item-meta span {
  padding: 4px 8px;
  color: var(--logo-k);
  background: #eef3ff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.item-actions {
  display: grid;
  gap: 8px;
  align-content: start;
}

.item-actions button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--logo-k);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 800;
}

.item-actions button:first-child {
  color: var(--white);
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  background: var(--white);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 320px;
  padding: 12px 14px;
  color: var(--white);
  background: var(--logo-k);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 960px) {
  .panel-hero,
  .admin-layout,
  .writer-admin-layout {
    grid-template-columns: 1fr;
  }

  .header-inner,
  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .admin-shell {
    width: min(100% - 24px, 1180px);
  }

  .hero-stats,
  .form-grid,
  .content-item,
  .content-item-main,
  .writer-item-main {
    grid-template-columns: 1fr;
  }

  .content-item-preview {
    width: 100%;
    max-height: 180px;
  }

  .writer-item-main img {
    width: 64px;
  }

  #list-search {
    max-width: none;
  }

  .admin-brand {
    align-items: flex-start;
    flex-direction: column;
  }
}
