:root {
  color-scheme: light;
  --paper: #f4f1e8;
  --surface: #fbfaf5;
  --ink: #272922;
  --muted: #666758;
  --line: #dedbcc;
  --olive: #414b37;
  --olive-dark: #303829;
  --sidebar: #232821;
  --gold: #d9be86;
  --danger: #912e29;
  --radius: 7px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.55 system-ui, "Microsoft YaHei", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid #8b6e32;
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.button {
  display: inline-flex;
  min-height: 40px;
  justify-content: center;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 8px 15px;
  font-weight: 650;
  white-space: nowrap;
}

.button-primary { background: var(--olive); color: white; }
.button-primary:hover { background: var(--olive-dark); }
.button-outline { background: var(--surface); border-color: var(--line); color: var(--ink); }
.button-outline:hover { background: #eeece1; }
.button-danger { background: var(--danger); color: #fff; }
.button-danger:hover { background: #74231f; }
.initial-status { margin: 36px auto; text-align: center; color: var(--muted); }
.notice { color: var(--muted); overflow-wrap: anywhere; }
.notice[data-error="true"] { color: var(--danger); }
.notice:empty { display: none; }

.workbench {
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  padding: 34px 20px 24px;
  background: var(--sidebar);
  color: #f3f1e5;
}

.sidebar-brand {
  display: grid;
  gap: 4px;
  padding: 0 13px 29px;
  border-bottom: 1px solid #ffffff22;
}

.studio-name { font-size: 24px; font-weight: 750; letter-spacing: .09em; }
.sidebar-brand > span:last-child { font-size: 12px; color: #c8c3b1; letter-spacing: .08em; }
.sidebar nav { display: grid; gap: 8px; margin: 20px 0; }
.sidebar nav a, .logout { padding: 10px 12px; border-radius: 4px; color: #e1ddcc; }
.sidebar nav a:hover, .logout:hover { background-color: #ffffff12; }
.sidebar nav .sidebar-active { background: #3a4334; box-shadow: inset 2px 0 var(--gold); color: #fff4da; }
.sidebar nav span { margin-left: 4px; color: var(--gold); }
.logout { margin-top: auto; text-align: left; border: 0; background: transparent; }
.sidebar :focus-visible { outline-color: var(--gold); }

.manage-content {
  width: min(100%, 1350px);
  margin: 0 auto;
  padding: 44px clamp(22px, 4.1vw, 66px) 58px;
}

.manage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 26px;
}

.manage-header h1 {
  margin: 0;
  font-size: clamp(29px, 3.1vw, 43px);
  letter-spacing: -.04em;
  line-height: 1.2;
}

.manage-header p { margin: 9px 0 0; color: var(--muted); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eceade;
}

.summary-item { padding: 15px clamp(12px, 2vw, 23px); }
.summary-item + .summary-item { border-left: 1px solid var(--line); }
.summary-item dt { font-size: 13px; color: var(--muted); }
.summary-item dd {
  margin: 3px 0 0;
  color: var(--olive-dark);
  font-family: Georgia, serif;
  font-size: 32px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.catalog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.catalog-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 20px clamp(12px, 2vw, 23px) 12px;
}

.catalog-heading h2 { margin: 0; font-size: 21px; }
.catalog-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.catalog-tools {
  display: grid;
  grid-template-columns: minmax(135px, 1fr) minmax(105px, auto) minmax(105px, auto);
  gap: 10px;
  padding: 0 clamp(12px, 2vw, 23px) 18px;
}

input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #d1cdbd;
  border-radius: 5px;
  padding: 8px 10px;
  background-color: #fffefa;
  color: var(--ink);
}

input, select { min-height: 39px; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #737365; opacity: 1; }
.catalog-notice { margin: 0; padding: 0 clamp(12px, 2vw, 23px) 12px; }
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; text-align: left; }
th {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f2efe5;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

td { padding: 9px 12px; vertical-align: middle; overflow-wrap: anywhere; }
th:first-child, td:first-child { width: 55%; padding-left: clamp(12px, 2vw, 23px); }
th:last-child, td:last-child { padding-right: clamp(12px, 2vw, 23px); }
tbody tr + tr { border-top: 1px solid var(--line); }
tbody tr:hover { background: #f7f5ed; }

.project-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.project-thumb {
  position: relative;
  display: grid;
  width: 38px;
  aspect-ratio: 3 / 4;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  background: #e8e5d8;
  color: var(--muted);
  border-radius: 3px;
}

.project-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-identity strong { display: block; font-size: 15px; }
.project-note { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.mobile-type { display: none; }
.published-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 4px;
  background: #ede9dd;
  color: #55513e;
  font-size: 12px;
  white-space: nowrap;
}

.published-status.is-public { background: #e4ecd9; color: #324e2b; }
.published-status::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.row-actions { display: flex; justify-content: flex-end; gap: 3px; }
.row-actions button {
  padding: 6px 8px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--olive);
  font-weight: 650;
  white-space: nowrap;
}

.row-actions button:hover { background: #eeece1; }
.row-actions .delete-project { color: var(--danger); }
.catalog-empty { padding: 33px 14px; border-top: 1px solid var(--line); text-align: center; }
.catalog-empty p { margin: 6px 0 12px; color: var(--muted); }

.settings-panel {
  margin-bottom: 20px;
  padding: clamp(16px, 2.4vw, 28px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.settings-heading { margin-bottom: 20px; }
.settings-heading h2 { margin: 0; font-size: 21px; }
.settings-heading p { margin: 5px 0 0; color: var(--muted); }
.settings-heading-actions { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.hero-settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.hero-settings-fields { display: grid; align-content: center; gap: 18px; }
.settings-image-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 6px; min-width: 0; }
.hero-settings-fields small { margin-left: 5px; font-weight: 400; color: var(--muted); }
.file-upload { min-height: 39px; padding-inline: 9px; cursor: pointer; font-size: 13px; }
.file-upload:focus-within { outline: 2px solid #8b6e32; outline-offset: 3px; }
.file-upload:has(input:disabled) { opacity: .55; cursor: wait; }
.hero-preview { margin: 0; }
.hero-preview-stage {
  position: relative;
  aspect-ratio: 16 / 8;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--sidebar);
}
.hero-preview-stage img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hero-preview-stage #heroPreviewForeground {
  position: absolute;
  bottom: 0;
  right: 5%;
  width: 65%;
  object-fit: contain;
  object-position: center bottom;
}
.hero-preview figcaption { margin-top: 6px; color: var(--muted); font-size: 12px; }

.social-settings-rows { display: grid; gap: 14px; }
.social-setting {
  min-width: 0;
  margin: 0;
  padding: 10px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.social-setting legend { padding: 0 6px; color: var(--olive-dark); font-weight: 700; }
.social-setting-name { display: flex; justify-content: space-between; align-items: end; gap: 8px; margin-bottom: 10px; }
.social-setting-name .field { width: min(100%, 275px); }
.remove-channel { color: var(--danger); font-size: 13px; }
.social-setting-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.settings-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-block: 10px;
  background: var(--paper);
}
.settings-actions .notice { margin: 0 auto 0 0; }
.settings-notice { margin-top: 12px; text-align: right; }

.access-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, .88fr);
  background: var(--surface);
}

.access-image {
  background: #292219 url("/assets/film-set.png") 67% center / cover;
}

.access-content {
  width: min(100%, 470px);
  margin: auto;
  padding: 38px clamp(28px, 5vw, 60px);
}

.access-content h1 {
  margin: 24px 0 22px;
  font-size: clamp(27px, 4vw, 36px);
  line-height: 1.2;
}

.access-content form .button { width: 100%; margin-top: 16px; }
.text-link { display: inline-block; margin-top: 22px; color: var(--olive); }
.text-link:hover { text-decoration: underline; }

dialog {
  max-height: calc(100dvh - 34px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 25px 75px #201d1650;
}

dialog::backdrop { background: #1d221bd1; }

.editor-dialog { width: min(820px, calc(100% - 26px)); }
.dialog-heading {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 13px 23px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.dialog-heading h2, .delete-dialog h2 { margin: 0; font-size: 22px; }
.close-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: #eeece1;
  color: var(--ink);
  font-size: 20px;
}

.close-button:hover { background: #e5e0d2; }
.editor-content { display: grid; grid-template-columns: minmax(0, 186px) minmax(0, 1fr); gap: 23px; padding: 20px 23px; }
.cover-group { min-width: 0; }
.cover-preview {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 3 / 4;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eeece1;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.cover-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-group small { display: block; margin-top: 6px; color: var(--muted); }
.editor-fields { display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: 13px; }
.editor-fields .wide { grid-column: 1 / -1; }
.field { display: grid; gap: 4px; font-size: 13px; font-weight: 650; }
.field input, .field select, .field textarea { font-weight: 400; }
.required { color: var(--danger); }
#publishHint { margin: -4px 0 4px; color: var(--muted); }

.dialog-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 12px 23px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.dialog-actions .notice { margin: 0 auto 0 0; }
.delete-dialog { width: min(440px, calc(100% - 26px)); }
.delete-dialog form { padding: 24px; }
.delete-dialog p { overflow-wrap: anywhere; }
.delete-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

@media (max-width: 950px) {
  .workbench { grid-template-columns: 178px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  th:first-child, td:first-child { width: auto; }
  .social-setting-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .social-setting-fields .settings-image-control { grid-column: 1 / -1; }
  .hero-settings-grid { gap: 14px; }
}

@media (max-width: 700px) {
  .workbench { display: block; }
  .sidebar {
    position: static;
    display: grid;
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px 12px;
    padding: 13px 17px 9px;
  }
  .sidebar-brand { padding: 0; border: 0; }
  .sidebar .studio-name { font-size: 19px; }
  .sidebar nav { grid-row: 2; grid-column: 1 / -1; display: flex; gap: 5px; margin: 0; }
  .sidebar nav { flex-wrap: wrap; }
  .sidebar nav a { padding-block: 5px; }
  .logout { grid-row: 1; grid-column: 2; padding: 7px 8px; }
  .manage-content { padding: 21px 13px 34px; }
  .access-layout { grid-template-columns: 1fr; grid-template-rows: minmax(185px, 34vh) 1fr; }
  .access-content { padding: 25px 22px; }
  .hero-settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 475px) {
  .manage-header { align-items: flex-start; margin-bottom: 17px; }
  .manage-header h1 { font-size: 27px; }
  .manage-header p { font-size: 13px; }
  .manage-header .button { padding-inline: 9px; }
  .summary-grid { margin-bottom: 16px; }
  .summary-item { padding-block: 10px; }
  .summary-item dt { font-size: 12px; }
  .summary-item dd { font-size: 27px; }
  .catalog-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .catalog-search { grid-column: 1 / -1; }
  .genre-cell { display: none; }
  .mobile-type { display: inline; }
  td, th { padding-inline: 5px; }
  .project-identity { gap: 7px; }
  .project-thumb { width: 29px; }
  .project-identity strong { font-size: 14px; }
  .row-actions { gap: 0; }
  .row-actions button { padding: 4px; font-size: 12px; }

  .editor-content { grid-template-columns: 1fr; padding: 13px; gap: 16px; }
  .cover-group { display: grid; grid-template-columns: 62px minmax(0, 1fr); column-gap: 12px; align-items: end; }
  .cover-preview { grid-row: span 2; margin: 0; font-size: 11px; }
  .cover-group small { align-self: start; }
  .dialog-heading, .dialog-actions { padding-inline: 13px; }
  .social-setting-fields { grid-template-columns: 1fr; }
  .settings-heading-actions { flex-wrap: wrap; }
}
