:root {
  --ink: #151412;
  --muted: #6e695f;
  --paper: #f6efe3;
  --panel: rgba(255, 252, 246, 0.86);
  --line: rgba(21, 20, 18, 0.13);
  --black: #0e0d0b;
  --gold: #a87938;
  --green: #2e6049;
  --wine: #713142;
  --shadow: 0 18px 48px rgba(30, 24, 17, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(46, 96, 73, 0.08), transparent 30%),
    linear-gradient(180deg, #f8f1e7 0%, #efe3d1 100%);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 12px clamp(16px, 4vw, 46px);
  color: #fff9ee;
  background: rgba(14, 13, 11, 0.92);
  border-bottom: 1px solid rgba(255, 249, 238, 0.14);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 900;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--black);
  background: var(--gold);
  font-family: SimSun, "Songti SC", serif;
  font-weight: 900;
}

.nav {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.nav a {
  padding: 8px 12px;
  color: rgba(255, 249, 238, 0.76);
  text-decoration: none;
}

.nav a:hover {
  color: #fff9ee;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button,
.admin-button,
.compact-button {
  min-height: 38px;
  border: 1px solid rgba(21, 20, 18, 0.16);
  color: #fff9ee;
  background: var(--black);
  font-weight: 800;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-color: rgba(255, 249, 238, 0.18);
  background: rgba(255, 249, 238, 0.08);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.month-wheel {
  position: relative;
}

.month-trigger svg {
  fill: rgba(255, 249, 238, 0.08);
}

.month-popover {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 30;
  width: 210px;
  padding: 16px;
  border: 1px solid rgba(255, 249, 238, 0.18);
  background: rgba(14, 13, 11, 0.96);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.26);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.month-wheel:hover .month-popover,
.month-wheel:focus-within .month-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.month-disc {
  --segments: 30;
  width: 160px;
  aspect-ratio: 1;
  margin: 0 auto;
  border: 1px solid rgba(255, 249, 238, 0.18);
  border-radius: 50%;
  background:
    repeating-conic-gradient(from -90deg, rgba(14, 13, 11, 0.5) 0deg 0.55deg, transparent 0.55deg calc(360deg / var(--segments))),
    var(--month-fill),
    rgba(255, 249, 238, 0.08);
  box-shadow: inset 0 0 0 12px rgba(14, 13, 11, 0.3);
}

.month-disc::after {
  content: "";
  display: block;
  width: 46px;
  aspect-ratio: 1;
  margin: 56px auto 0;
  border-radius: 50%;
  background: #0e0d0b;
  border: 1px solid rgba(255, 249, 238, 0.18);
}

.month-caption {
  margin: 12px 0 0;
  color: rgba(255, 249, 238, 0.76);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.admin-button,
.compact-button {
  padding: 0 16px;
}

.compact-button.secondary {
  color: var(--ink);
  background: transparent;
}

.admin-button.is-active {
  color: var(--black);
  background: #fff9ee;
}

.admin-only {
  display: none;
}

body.admin .admin-only {
  display: inline-flex;
  align-items: center;
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(620px, 1.75fr) minmax(320px, 0.9fr);
  align-items: start;
  gap: 16px;
  width: min(1760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 52px;
}

.main-column {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.hero,
.panel,
.court-sticky,
.side-sticky {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero {
  padding: clamp(20px, 2.4vw, 34px) clamp(22px, 3vw, 40px);
  background:
    linear-gradient(135deg, rgba(168, 121, 56, 0.14), transparent 36%),
    rgba(255, 252, 246, 0.82);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1,
.panel h2,
.court-sidebar h2,
.modal h3,
.featured-log h3 {
  margin: 0;
  font-family: SimSun, "Songti SC", serif;
  letter-spacing: 0;
}

.hero h1 {
  max-width: 780px;
  font-size: clamp(2rem, 3.3vw, 3.6rem);
  line-height: 1.08;
}

.hero-line {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.22rem);
  line-height: 1.85;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.hero-meta span,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.72);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.section-head,
.sidebar-head,
.archive-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel h2,
.court-sidebar h2 {
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.featured-log {
  padding: 22px 24px 26px;
  border-bottom: 1px solid var(--line);
}

.featured-log h3 {
  font-size: clamp(1.75rem, 3vw, 3rem);
  line-height: 1.12;
}

.featured-log .log-date {
  margin: 0 0 10px;
}

.featured-log .log-body {
  margin: 14px 0 0;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.85;
  white-space: pre-wrap;
}

.log-list,
.task-list,
.court-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.log-item,
.task-item,
.court-item,
.advisor-card {
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.72);
}

.advisor-card.is-hidden {
  display: none;
}

.log-item {
  padding: 16px 18px;
}

.log-item h3,
.task-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 900;
}

.log-item p,
.task-note,
.court-message,
.advisor-comment {
  color: var(--muted);
  line-height: 1.7;
}

.log-body {
  white-space: pre-wrap;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.task-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 16px;
}

.task-item.done {
  opacity: 0.58;
}

.task-check {
  display: none;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  color: transparent;
  background: transparent;
}

body.admin .task-check {
  display: grid;
}

.task-item.done .task-check {
  color: #fff9ee;
  background: var(--green);
}

.delete-button {
  display: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  color: var(--wine);
  background: transparent;
  font-size: 20px;
  line-height: 1;
}

body.admin .delete-button {
  display: block;
}

.court-sidebar,
.plan-sidebar {
  min-width: 0;
}

.court-sticky,
.side-sticky {
  position: static;
}

.sidebar-head {
  align-items: flex-start;
}

.advisor-card {
  margin: 16px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(113, 49, 66, 0.08), transparent 45%),
    rgba(255, 252, 246, 0.82);
}

.advisor-role,
.court-name {
  margin: 0;
  color: var(--gold);
  font-weight: 900;
}

.advisor-card h3 {
  margin-top: 4px;
  font-size: 1.3rem;
}

.advisor-comment {
  margin: 12px 0 0;
  white-space: pre-wrap;
}

.advisor-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.advisor-intro {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.75;
}

.advisor-panel {
  border-bottom: 1px solid var(--line);
}

.advisor-thread {
  display: grid;
  gap: 10px;
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--line);
}

.thread-message {
  padding: 12px 13px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.6);
}

.thread-message.is-admin {
  border-color: rgba(46, 96, 73, 0.22);
  background: rgba(46, 96, 73, 0.08);
}

.thread-speaker {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 7px;
  color: var(--gold);
  font-size: 0.88rem;
  font-weight: 900;
}

.thread-intro,
.court-intro {
  display: block;
  width: 100%;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.45;
}

.thread-body {
  margin: 0;
  color: var(--muted);
  line-height: 1.72;
  white-space: pre-wrap;
}

.advisor-reply-form {
  display: none;
  gap: 10px;
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--line);
}

body.admin .advisor-reply-form.admin-only {
  display: grid;
}

.advisor-reply-form .compact-button {
  justify-self: end;
}

.guestbook-form {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--line);
}

body.admin .guestbook-form {
  display: none;
}

.guestbook-form .compact-button {
  justify-self: end;
}

.message-board-title {
  padding: 16px 16px 0;
}

.message-board-title h3 {
  margin: 0;
  font-family: SimSun, "Songti SC", serif;
  font-size: 1.25rem;
}

.court-item {
  padding: 14px;
}

.court-replies {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-left: 12px;
  border-left: 2px solid rgba(168, 121, 56, 0.22);
}

.court-reply {
  padding: 10px 11px;
  background: rgba(255, 252, 246, 0.7);
  border: 1px solid var(--line);
}

.court-reply-name {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 0.84rem;
  font-weight: 900;
}

.court-reply-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.court-reply-form {
  display: none;
  gap: 8px;
  margin-top: 12px;
}

body.admin .court-reply-form {
  display: grid;
}

.court-reply-form .compact-button {
  justify-self: end;
}

.court-title,
.court-time {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 16px 16px;
}

.pager-info {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.court-message {
  display: block;
  margin-top: 10px;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed rgba(21, 20, 18, 0.2);
  background: rgba(255, 252, 246, 0.58);
}

.modal {
  width: min(620px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(14, 13, 11, 0.62);
  backdrop-filter: blur(5px);
}

.modal-card {
  display: grid;
  gap: 15px;
  padding: 24px;
  border: 1px solid rgba(255, 249, 238, 0.5);
  background: #fff9ee;
  box-shadow: var(--shadow);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-actions {
  justify-content: flex-end;
}

.ghost-icon {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 22px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid rgba(21, 20, 18, 0.18);
  background: #fffdf8;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

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

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--wine);
  font-weight: 800;
}

@media (max-width: 1180px) {
  .page-grid {
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  }

  .court-sidebar {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .nav {
    display: none;
  }

  .page-grid {
    grid-template-columns: 1fr;
  }

  .side-sticky,
  .court-sticky {
    position: static;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 10px 12px;
  }

  .page-grid {
    padding: 14px 12px 38px;
  }

  .hero,
  .featured-log {
    padding: 22px 18px;
  }

  .section-head,
  .sidebar-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-row,
  .task-item {
    grid-template-columns: 1fr;
  }
}
