:root {
  color-scheme: light;
  --ink: #101820;
  --blue: #dceeff;
  --blue-strong: #9fcbed;
  --blue-dark: #174d73;
  --line: #bfd4e4;
  --paper: #ffffff;
  --danger: #8a2020;
  font-family: "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.8;
}

button, input, textarea { font: inherit; color: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid var(--blue-dark);
  outline-offset: 3px;
}

.hidden { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.top-nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: 60px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.nav-inner {
  display: flex;
  max-width: 1440px;
  height: 60px;
  margin: 0 auto;
  padding: 10px 80px;
}

.nav-item {
  display: inline-flex;
  flex: 0 0 150px;
  align-items: center;
  justify-content: center;
  height: 40px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.nav-item:first-child { border-left: 1px solid var(--line); }
.nav-item.active { background: var(--blue); box-shadow: inset 0 -3px 0 var(--blue-dark); }
.nav-button { font-size: 16px; }

.page-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 110px 80px 64px;
}
.front-page-shell { padding-top: 90px; }

.hero { margin-bottom: 50px; }
.admin-hero { margin-bottom: 38px; }
.main-title { margin: 0; font-size: 50px; line-height: 1.25; letter-spacing: -0.04em; }
.subtitle { margin: 12px 0 4px; font-size: 26px; line-height: 1.5; }
.generated-time, .section-meta { color: var(--ink); font-size: 14px; }

.section-block {
  position: relative;
  padding-top: 41px;
  border-top: 1px solid var(--line);
}
.content-section { padding-top: 20px; }

.section-block h2 { margin: 0 0 12px; font-size: 22px; line-height: 1.5; }
.section-meta { margin: 0 0 20px; }

.status-banner {
  margin: -20px 0 30px;
  padding: 10px 14px;
  border: 1px solid var(--blue-strong);
  background: var(--blue);
  color: var(--ink);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.text-card {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  height: 240px;
  min-height: 0;
  padding: 22px;
  border: 1px solid var(--line);
  background: var(--paper);
  text-align: left;
  cursor: copy;
  user-select: text;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.text-card:hover { border-color: var(--blue-dark); box-shadow: 0 5px 18px rgba(23, 77, 115, 0.1); }
.text-card:active { background: #f4faff; }
.card-header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.card-title { margin: 0; font-size: 27px; line-height: 1.35; }
.card-date { flex: 0 0 auto; font-size: 13px; }
.card-content {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.8;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}
.copy-label { display: block; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); color: var(--blue-dark); font-weight: 700; }
.empty-state { padding: 24px; border: 1px solid var(--line); text-align: center; }

.toast {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 16px;
  border: 1px solid var(--blue-dark);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 8px 30px rgba(16, 24, 32, 0.18);
}

.toast button { margin-left: 16px; border: 0; border-bottom: 1px solid var(--ink); background: transparent; cursor: pointer; font-weight: 700; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px; }
.login-panel { width: min(460px, 100%); padding: 36px; border: 1px solid var(--line); }
.login-header { margin-bottom: 26px; }
.login-header h1 { margin: 0; font-size: 30px; }
.login-header p { margin: 8px 0 0; }

label { display: block; margin: 16px 0 6px; font-weight: 700; }
input, textarea {
  width: 100%;
  border: 1px solid var(--blue-dark);
  border-radius: 0;
  background: var(--paper);
  padding: 10px 12px;
}
textarea { resize: vertical; min-height: 180px; line-height: 1.7; }
.form-message { min-height: 30px; margin: 8px 0; color: var(--danger); }

.primary-button, .secondary-button {
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid var(--blue-dark);
  border-radius: 0;
  cursor: pointer;
}
.primary-button { background: var(--blue); font-weight: 700; }
.secondary-button { background: var(--paper); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
.full-width { width: 100%; }

.section-heading-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.admin-actions-heading { justify-content: flex-end; }
.action-row, .dialog-actions { display: flex; gap: 10px; }
.admin-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.admin-table-header {
  display: grid;
  grid-template-columns: 64px minmax(180px, 1fr) minmax(220px, 2fr) auto;
  gap: 18px;
  padding: 10px 0;
  border-bottom: 1px solid var(--blue-dark);
  font-size: 14px;
  font-weight: 700;
}
.admin-table-header span:last-child { min-width: 184px; text-align: right; }
.admin-row {
  display: grid;
  grid-template-columns: 64px minmax(180px, 1fr) minmax(220px, 2fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 164px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.admin-number {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--blue-dark);
  background: var(--blue);
  font-weight: 700;
}
.admin-row.dragging { opacity: 0.45; }
.admin-title { margin: 0; font-size: 18px; }
.admin-date { display: block; font-size: 13px; }
.admin-preview { margin: 0; white-space: pre-line; overflow: hidden; display: -webkit-box; line-height: 1.7; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.row-actions button { min-width: 56px; min-height: 44px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; }
.row-actions .danger-button { border-color: var(--danger); color: var(--danger); }

.edit-dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--blue-dark); }
.edit-dialog::backdrop { background: rgba(16, 24, 32, 0.4); }
.edit-dialog form { padding: 28px; }
.dialog-header { border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.dialog-header h2 { margin: 0 0 14px; font-size: 22px; }
.dialog-actions { justify-content: flex-end; margin-top: 20px; }

@media (max-width: 780px) {
  .nav-inner { padding: 10px 12px; }
  .nav-item { flex: 1 1 0; min-width: 0; font-size: 15px; }
  .page-shell { padding: 96px 20px 48px; }
  .front-page-shell { padding-top: 80px; }
  .hero { margin-bottom: 38px; }
  .main-title { font-size: 38px; }
  .subtitle { font-size: 21px; }
  .card-grid { grid-template-columns: 1fr; }
  .text-card { height: 240px; min-height: 0; padding: 18px; }
  .section-heading-row { align-items: stretch; flex-direction: column; }
  .admin-actions-heading { align-items: stretch; }
  .action-row { display: grid; grid-template-columns: 1fr 1fr; }
  .admin-row { grid-template-columns: 1fr; min-height: 0; gap: 8px; padding: 18px 0; }
  .admin-table-header { display: none; }
  .admin-number { margin-bottom: 2px; }
  .row-actions { justify-content: flex-start; }
  .row-actions button { flex: 1 1 64px; }
  .login-panel { padding: 26px 22px; }
  .toast { right: 16px; bottom: 16px; max-width: calc(100vw - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
