:root {
  --ink: #233544;
  --muted: #536573;
  --brand: #3e5e7b;
  --line: #d4dde3;
  --paper: #f5f6f7;
  --danger: #a2252c;
  --sidebar: 238px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font:
    15px/1.65 -apple-system,
    BlinkMacSystemFont,
    "Noto Sans TC",
    "Microsoft JhengHei",
    sans-serif;
}
a {
  color: #315d7d;
  text-underline-offset: 4px;
}
a:hover {
  color: #173a55;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: wait;
  opacity: 0.6;
}
:focus-visible {
  outline: 3px solid #d88a24;
  outline-offset: 3px;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 30px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}
h2 {
  font-size: 20px;
  line-height: 1.4;
}
h3 {
  font-size: 17px;
}
.skip {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 100;
  background: white;
  padding: 12px;
}
.skip:focus {
  top: 8px;
}
.topbar {
  height: 68px;
  position: fixed;
  inset: 0 0 auto;
  background: #203544;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 30;
  color: white;
  border-bottom: 1px solid #536573;
}
.topbar a {
  color: white;
  text-decoration: none;
}
.brand {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.account {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 14px;
}
.account form {
  display: contents;
}
.text-button {
  border: 0;
  padding: 6px 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.sidebar {
  position: fixed;
  top: 68px;
  bottom: 0;
  left: 0;
  width: var(--sidebar);
  overflow: auto;
  background: white;
  border-right: 1px solid var(--line);
  padding: 22px 14px;
}
.sidebar a {
  display: block;
  padding: 9px 14px;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar a:hover,
.sidebar a[aria-current="page"] {
  background: #eaf0f4;
  border-left-color: var(--brand);
  color: #203544;
}
.site-context,
.nav-group {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 16px;
}
.site-context strong,
.nav-group > span {
  display: block;
  padding: 0 14px 10px;
  color: var(--muted);
  font-size: 13px;
}
.site-context strong {
  color: var(--ink);
  font-size: 15px;
}
.workspace {
  margin-left: var(--sidebar);
  padding: 106px 40px 24px;
  max-width: 1580px;
  min-height: 100vh;
}
.workspace-footer {
  margin-top: 56px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 30px;
}
.page-heading p {
  color: var(--muted);
  max-width: 70ch;
  margin-bottom: 0;
}
.page-heading .button {
  flex-shrink: 0;
}
.back {
  display: inline-block;
  font-size: 13px;
  margin-bottom: 12px;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 42px;
  padding: 9px 18px;
  border: 1px solid #aab9c4;
  border-radius: 4px;
  background: white;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.button:hover {
  background: #eaf0f4;
  color: var(--ink);
}
.button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}
.button.primary:hover {
  background: #294b67;
}
.button.danger {
  border-color: var(--danger);
  color: var(--danger);
}
.danger {
  color: var(--danger);
}
.list-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.list-filter label {
  font-weight: 600;
  font-size: 14px;
}
.list-filter select {
  width: auto;
  min-width: 140px;
}
.table-wrap {
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 4px;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th {
  background: #edf1f4;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
th,
td {
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tr:last-child td {
  border-bottom: 0;
}
td strong {
  font-weight: 600;
}
td small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}
td:first-child {
  min-width: 180px;
}
.site-list .site-code {
  min-width: 128px;
  width: 1%;
  white-space: nowrap;
}
.site-list td:nth-child(2) { min-width: 240px; }
tbody tr:hover {
  background: #fafcfd;
}
.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-width: 120px;
  font-size: 14px;
}
.row-actions form {
  display: contents;
}
.status {
  display: inline-block;
  border: 1px solid;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}
.status.enabled {
  color: #235c41;
  background: #edf5ef;
  border-color: #b0ceba;
}
.status.disabled {
  color: #5a636a;
  background: #f2f3f4;
  border-color: #ced4d8;
}
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.form-section {
  background: white;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 28px;
  margin-bottom: 24px;
}
.form-section h2 {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
}
.field {
  margin-bottom: 22px;
  min-width: 0;
}
.field:last-child {
  margin-bottom: 12px;
}
.field > label {
  display: block;
  font-weight: 600;
  margin-bottom: 7px;
  font-size: 14px;
}
input:not([type="checkbox"]):not([type="file"]),
select,
textarea {
  display: block;
  width: 100%;
  border: 1px solid #9eafb9;
  border-radius: 3px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  min-height: 43px;
}
textarea {
  min-height: 160px;
  resize: vertical;
}
input[type="file"] {
  max-width: 100%;
  display: block;
  margin: 10px 0;
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  flex-shrink: 0;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
}
small,
.hint {
  color: var(--muted);
  font-size: 13px;
}
.field small {
  display: block;
  margin-top: 6px;
}
.check {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: 10px 0;
  font-weight: 400 !important;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  bottom: 0;
  background: #f5f6f7f5;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  z-index: 10;
}
.upload-tools {
  background: #f1f5f7;
  padding: 18px;
  margin-bottom: 24px;
}
.upload-result {
  display: block;
  overflow-wrap: anywhere;
  margin: 12px 0;
  font-size: 13px;
}
.image-preview {
  max-width: 320px;
  max-height: 180px;
  object-fit: contain;
}
.site-image-preview[hidden] { display: none; }
.brand-image-group { margin-top: 32px; }
.brand-image-group > h3 {
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 20px;
}
.site-image-field {
  min-inline-size: 0;
  padding: 0;
  border: 0;
  margin: 0 0 28px;
}
.site-image-field + .site-image-field { padding-top: 24px; border-top: 1px solid var(--line); }
.site-image-field > legend { padding: 0 0 16px; font-size: 15px; font-weight: 600; }
.site-image-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: start;
  gap: 28px;
}
.site-image-visual, .site-image-controls { min-width: 0; }
.site-image-controls { display: grid; gap: 16px; }
.image-setting textarea { min-height: 88px; }
.image-setting > label, .site-image-controls > label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 7px;
}
.site-image-controls .site-image-upload-label { margin: 0; font-weight: 600 !important; }
.site-image-controls input[type="file"] { margin-bottom: 0; }
.site-image-visual:has(.site-image-preview[hidden]) .site-image-status {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  margin: 0;
  padding: 24px;
  border: 1px solid var(--line);
  background: var(--paper);
}
@media (max-width: 1100px) {
  .site-image-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .site-image-field .site-image-open img { height: auto; max-height: 220px; }
}
.site-image-open {
  display: block;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  cursor: zoom-in;
}
.site-image-open:hover { border-color: var(--brand); }
.site-image-open img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: contain;
}
.site-image-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 10px;
}
.site-image-status { margin: 10px 0; }
.site-image-status:empty { display: none; }
.site-image-upload-label {
  margin-top: 14px;
  font-weight: 400 !important;
}
.site-image-field input[type="file"]::file-selector-button {
  padding: 8px 12px;
  border: 1px solid #aab9c4;
  border-radius: 3px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  margin-right: 8px;
}
.image-dialog-open { overflow: hidden; }
.site-image-dialog {
  width: min(1200px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  color: var(--ink);
}
.site-image-dialog::backdrop { background: #203544c9; }
.site-image-dialog-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.site-image-dialog-toolbar h2 { flex: 1; margin: 0; min-width: 160px; }
.site-image-dialog-canvas {
  overflow: auto;
  height: min(65dvh, 760px);
  background: var(--paper);
}
.site-image-dialog-canvas img { display: block; width: 100%; height: 100%; object-fit: contain; }
.site-image-dialog-canvas.original-size img { width: auto; height: auto; max-width: none; max-height: none; }
.site-image-dialog-status { margin: 12px 0 0; }
@media (max-width: 760px) {
  .site-image-dialog { padding: 16px; }
  .site-image-dialog-toolbar { gap: 8px; }
  .site-image-dialog-toolbar h2 { flex-basis: 100%; }
  .site-image-dialog-canvas { height: 55dvh; }
}
.notice {
  background: #edf5ef;
  border: 1px solid #a3c7b1;
  padding: 14px 18px;
  margin-bottom: 24px;
}
.preserve-lines {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.narrow {
  max-width: 640px;
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 24px;
  border-top: 1px solid var(--line);
}
.module-link {
  display: block;
  padding: 22px 8px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  font-weight: 600;
}
.module-link span {
  float: right;
}
.summary-strip {
  display: flex;
  gap: 24px;
  padding: 22px 0;
  border-block: 1px solid var(--line);
  margin-bottom: 30px;
}
.summary-strip strong {
  font-size: 26px;
}
.menu-toggle {
  display: none;
}
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: white;
}
.login-story {
  background: #203544;
  color: white;
  padding: clamp(40px, 8vw, 120px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-story h1 {
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.45;
  margin: 28px 0;
}
.login-story p {
  color: #d2dfe8;
  max-width: 32em;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.login-panel {
  padding: 50px;
  align-self: center;
  width: 100%;
  max-width: 520px;
  justify-self: center;
}
.login-panel h2 {
  font-size: 26px;
  margin-bottom: 8px;
}
.login-panel form {
  margin-top: 32px;
}
.login-panel .button {
  width: 100%;
  margin-top: 10px;
}
.login-panel .field {
  margin-bottom: 22px;
}
.error-message {
  background: #fbeeee;
  border: 1px solid #dab0b3;
  padding: 14px;
  color: #85242a;
}
.error-page {
  max-width: 680px;
  margin: 15vh auto;
  padding: 30px;
}
.error-code {
  font-size: 60px;
  color: var(--brand);
  font-weight: 700;
}
.error-page .row-actions {
  margin-top: 28px;
}
.login-note {
  font-size: 12px;
  margin-top: 26px;
  color: var(--muted);
}
@media (max-width: 1100px) {
  .workspace {
    padding-inline: 24px;
  }
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .account {
    gap: 12px;
  }
}
@media (max-width: 760px) {
  .topbar {
    padding: 0 16px;
    height: 60px;
    gap: 12px;
  }
  .brand {
    font-size: 16px;
  }
  .account > span {
    display: none;
  }
  .account {
    font-size: 12px;
    gap: 10px;
  }
  .menu-toggle {
    display: block;
    background: none;
    border: 1px solid #93a5b2;
    border-radius: 3px;
    color: inherit;
    padding: 7px 9px;
  }
  .sidebar {
    top: 60px;
    transform: translateX(-100%);
    z-index: 25;
    width: 260px;
    box-shadow: 6px 0 16px #2335441a;
  }
  .menu-open .sidebar {
    transform: translateX(0);
  }
  .workspace {
    margin-left: 0;
    padding: 88px 18px 20px;
  }
  .page-heading {
    flex-wrap: wrap;
    margin-bottom: 24px;
    gap: 16px;
  }
  h1 {
    font-size: 26px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-section {
    padding: 20px;
  }
  .module-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0 14px;
  }
  td,
  th {
    padding: 12px 14px;
  }
  .login-page {
    grid-template-columns: 1fr;
  }
  .login-story {
    padding: 32px 26px;
  }
  .login-story h1 {
    font-size: 28px;
    margin: 12px 0;
  }
  .login-story p {
    margin-bottom: 0;
  }
  .login-panel {
    padding: 32px 26px;
  }
  .form-actions {
    bottom: 0;
  }
  .account .text-button {
    font-size: 12px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .sidebar {
    transition: transform 0.18s ease;
  }
  a,
  button {
    transition: background-color 0.15s ease;
  }
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}
.section-heading h2 {
  margin: 0;
}
.backup-section {
  margin-top: 36px;
}
.module-link {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.module-link span {
  float: none;
}
.muted {
  color: var(--muted);
}

.icon {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

.current-site {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin: 0 0 26px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.current-site > span {
  font-size: 12px;
  color: var(--muted);
}
.current-site a {
  font-weight: 600;
}
.current-site code {
  font-family: inherit;
  color: var(--muted);
  font-size: 12px;
}
@media (max-width: 760px) {
  .current-site {
    margin-bottom: 22px;
  }
  .current-site > span {
    flex-basis: 100%;
  }
}

/* Site publication controls follow the existing admin form layout. */
.publication-section { scroll-margin-top: 90px; }
.publication-section > p { max-width: 70ch; }
.publication-form { max-width: 720px; }
.publication-state { max-width: 280px; }
.publication-reason[hidden] { display: none; }
.publication-actions { margin: 16px 0 24px; }
.publication-history { border-top: 1px solid var(--line); padding-top: 16px; }
.publication-history summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.publication-history .table-wrap { margin-top: 16px; }
.publication-history td { vertical-align: top; }
.publication-history time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.publication-history td:last-child { min-width: 240px; max-width: 600px; }

/* Nested site navigation uses native disclosure controls, including without JavaScript. */
.site-context > summary,
.site-menu-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  padding: 10px 14px;
  border-radius: 3px;
}
.site-context > summary::-webkit-details-marker,
.site-menu-group > summary::-webkit-details-marker { display: none; }
.site-context > summary strong { padding: 0; min-width: 0; overflow-wrap: anywhere; }
.site-context > summary:hover,
.site-menu-group > summary:hover { background: #eaf0f4; }
.nav-chevron { flex-shrink: 0; }
details[open] > summary > .nav-chevron { transform: rotate(90deg); }
.site-menu-body { margin-top: 8px; }
.site-menu-group + .site-menu-group { margin-top: 4px; }
.site-menu-group > summary { color: var(--muted); font-size: 14px; font-weight: 600; }
.site-menu-group[open] > summary { color: var(--ink); }
.site-menu-group a { padding-left: 28px; }
.site-public-link { margin-top: 12px; }

/* Overview uses the same group order and routes as the site navigation. */
.dashboard-groups {
  border-top: 1px solid var(--line);
}
.dashboard-group {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.dashboard-group h3 {
  margin: 0;
  padding: 16px 8px;
  font-size: 16px;
}
.dashboard-group .module-grid {
  border-top: 0;
}
.dashboard-group .module-link {
  align-items: center;
  padding: 16px 8px;
  border-bottom: 0;
  min-width: 0;
}
.dashboard-group .module-link .muted {
  font-size: 12px;
  font-weight: 400;
}
.dashboard-group .module-link .icon {
  flex-shrink: 0;
}
@media (max-width: 1100px) {
  .dashboard-group {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .dashboard-group h3 {
    padding: 0 8px;
  }
}
@media (max-width: 760px) {
  .dashboard-group .module-grid {
    grid-template-columns: 1fr;
  }
}

.impersonation-banner {
  position: sticky;
  top: 68px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px;
  margin-bottom: 28px;
  border: 1px solid var(--input-border-admin, #9eafb9);
  background: var(--nav-active, #eaf0f4);
}
.impersonation-banner p {
  margin: 4px 0 0;
  font-size: 14px;
}
.impersonation-banner form {
  flex-shrink: 0;
}
.site-grant-heading {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 16px;
  padding: 12px 0 12px 32px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.check.site-grant {
  display: grid;
  grid-template-columns: 16px 140px minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  padding: 12px 0;
  margin: 0;
  border-bottom: 1px solid var(--line);
}
.site-grant input { margin-top: 4px; }
.site-grant code { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .impersonation-banner { top: 60px; flex-direction: column; align-items: stretch; gap: 12px; }
  .impersonation-banner .button { width: 100%; }
  .site-grant-heading { grid-template-columns: 104px minmax(0, 1fr); gap: 12px; padding-left: 28px; }
  .check.site-grant { grid-template-columns: 16px 104px minmax(0, 1fr); gap: 12px; }
}

/* Dedicated-domain settings follow the existing form's field and divider rhythm. */
.domain-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 0 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.domain-row .field { margin-bottom: 8px; }
.domain-remove { align-self: start; margin-top: 30px; }
.domain-destination { grid-column: 1 / -1; margin: 0; overflow-wrap: anywhere; }
.domain-settings [data-domain-add] { margin-top: 20px; }
.domain-primary { margin-top: 28px; }
.domain-primary p { overflow-wrap: anywhere; }
.domain-settings [hidden] { display: none; }
@media (max-width: 760px) {
  .domain-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .domain-remove { margin-top: 0; justify-self: start; }
}
