:root {
  --ink: #17324d;
  --ink-soft: #41586f;
  --paper: #f5f0e6;
  --paper-light: #fffdf8;
  --line: #d8d0c1;
  --line-strong: #a89e8b;
  --red: #a53a32;
  --red-dark: #7d2823;
  --green: #41766a;
  --green-pale: #dceae5;
  --blue-pale: #e2eaf0;
  --gold: #c39a4a;
  --shadow: 0 1.5rem 4rem rgba(33, 44, 55, 0.12);
  --radius: 0.9rem;
  font-family: "Noto Sans TC", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 20rem; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--paper); font-size: 1rem; line-height: 1.5; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.paper-grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.42;
  background-image: radial-gradient(rgba(23, 50, 77, 0.1) 0.6px, transparent 0.7px);
  background-size: 0.35rem 0.35rem;
  mask-image: linear-gradient(to bottom, #000, transparent 80%);
}

.eyebrow, .section-kicker { margin: 0 0 0.45rem; color: var(--red); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.16em; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: "Noto Serif TC", serif; line-height: 1.18; }

.button {
  min-height: 2.75rem; border: 1px solid transparent; border-radius: 999px; padding: 0.68rem 1.15rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; font-weight: 700; transition: 160ms ease;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .icon-button:focus-visible, input:focus-visible, select:focus-visible, .day-tab:focus-visible { outline: 3px solid rgba(165, 58, 50, 0.28); outline-offset: 2px; }
.button-primary { color: white; background: var(--red); box-shadow: 0 0.4rem 1rem rgba(165, 58, 50, 0.2); }
.button-primary:hover { background: var(--red-dark); }
.button-secondary { color: var(--ink); background: var(--paper-light); border-color: var(--line-strong); }
.button-ghost { color: var(--ink-soft); background: transparent; border-color: var(--line); }
.button-danger { color: white; background: var(--red); }
.button:disabled { opacity: 0.55; cursor: wait; transform: none; }

.login-view { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.login-panel { padding: clamp(2rem, 8vw, 7rem) max(1.25rem, calc((100vw - 78rem) / 2)); display: flex; flex-direction: column; justify-content: center; }
.login-panel h1 { max-width: 13ch; margin-bottom: 1.4rem; font-size: clamp(2.15rem, 7vw, 4.8rem); letter-spacing: -0.045em; }
.login-copy { max-width: 36rem; color: var(--ink-soft); font-size: 1.05rem; }
.seal { width: 4.7rem; height: 4.7rem; margin-bottom: 2rem; border: 0.22rem double var(--red); display: grid; place-items: center; color: var(--red); font-family: "Noto Serif TC", serif; font-weight: 900; line-height: 1.05; transform: rotate(-3deg); }
.login-form { max-width: 38rem; margin-top: 1rem; }
.login-form label { display: block; margin-bottom: 0.45rem; font-size: 0.88rem; font-weight: 700; }
.login-row { display: grid; gap: 0.7rem; }
.login-row input { min-height: 3rem; width: 100%; border: 1px solid var(--line-strong); border-radius: 999px; padding: 0.7rem 1rem; background: var(--paper-light); color: var(--ink); }
.form-message { min-height: 1.5rem; margin: 0.75rem 0 0; color: var(--green); font-size: 0.88rem; }
.login-aside { display: none; }

.site-header { min-height: 4.7rem; padding: 0.7rem 1rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: rgba(245, 240, 230, 0.9); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20; }
.brand { min-width: 0; display: flex; align-items: center; gap: 0.7rem; color: inherit; text-decoration: none; }
.brand-mark { width: 2.65rem; height: 2.65rem; flex: 0 0 auto; display: grid; place-items: center; color: white; background: var(--red); border-radius: 0.25rem; font-family: "Noto Serif TC", serif; font-size: 1.35rem; font-weight: 900; box-shadow: inset 0 0 0 2px rgba(255,255,255,.24); }
.brand strong, .brand small { display: block; white-space: nowrap; }
.brand strong { font-family: "Noto Serif TC", serif; font-size: 1.08rem; }
.brand small { color: var(--ink-soft); font-size: 0.7rem; }
.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.user-chip { display: none; align-items: center; gap: 0.45rem; color: var(--ink-soft); font-size: 0.82rem; }
.status-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0.2rem var(--green-pale); }

.demo-banner { padding: 0.65rem 1rem; display: flex; flex-direction: column; gap: 0.15rem; color: #563f13; background: #f4e2b5; border-bottom: 1px solid #dfc57f; font-size: 0.82rem; text-align: center; }
.main-content { width: 100%; max-width: 100rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.hero-row { margin-bottom: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }
.hero-row h1 { margin-bottom: 0.55rem; font-size: clamp(2rem, 8vw, 3.7rem); letter-spacing: -0.035em; }
.hero-copy { margin: 0; color: var(--ink-soft); }
.hero-actions { display: grid; grid-template-columns: 1fr; gap: 0.65rem; }

.schedule-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: rgba(255, 253, 248, 0.76); box-shadow: var(--shadow); }
.schedule-toolbar { padding: 1.1rem; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 1rem; }
.schedule-toolbar h2 { margin: 0; font-size: 1.45rem; }
.legend { display: flex; flex-wrap: wrap; gap: 0.85rem; color: var(--ink-soft); font-size: 0.78rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend i { width: 0.72rem; height: 0.72rem; border: 1px solid var(--line-strong); border-radius: 0.15rem; }
.legend-free { background: var(--paper-light); }
.legend-booked { background: var(--blue-pale); }
.legend-own { background: var(--green-pale); }
.public-status { display: flex; }

.day-tabs { padding: 0.65rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; border-bottom: 1px solid var(--line); background: #efe9dd; }
.day-tab { min-height: 2.75rem; border: 1px solid transparent; border-radius: 0.55rem; background: transparent; color: var(--ink-soft); font-weight: 700; }
.day-tab[aria-selected="true"] { color: white; background: var(--ink); box-shadow: 0 0.4rem 0.9rem rgba(23,50,77,.18); }

.loading-state { min-height: 14rem; display: flex; align-items: center; justify-content: center; gap: 0.7rem; color: var(--ink-soft); }
.loader { width: 1.2rem; height: 1.2rem; border: 2px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.desktop-schedule { display: none; overflow-x: auto; overscroll-behavior-inline: contain; }
.schedule-table { width: 100%; min-width: 82rem; border-collapse: separate; border-spacing: 0; table-layout: fixed; background: var(--paper-light); }
.schedule-table th, .schedule-table td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.schedule-table thead th { height: 3.1rem; padding: 0.4rem; position: sticky; top: 4.7rem; z-index: 3; color: var(--ink); background: #ece5d8; font-family: "Noto Serif TC", serif; font-size: 0.82rem; }
.schedule-table .time-head, .schedule-table .time-cell { width: 6rem; position: sticky; left: 0; z-index: 2; background: #ece5d8; }
.schedule-table .time-head { z-index: 4; }
.schedule-table .time-cell { padding: 0.5rem; text-align: center; font-size: 0.74rem; font-weight: 700; }
.schedule-cell { height: 4.4rem; padding: 0.3rem; vertical-align: top; background: var(--paper-light); }
.booking-chip { width: 100%; min-height: 3.75rem; border: 1px solid #b7c8d4; border-radius: 0.45rem; padding: 0.4rem; display: flex; flex-direction: column; gap: 0.1rem; overflow: hidden; color: var(--ink); background: var(--blue-pale); text-align: left; }
.booking-chip.is-own { border-color: #8bad9f; background: var(--green-pale); }
.booking-chip strong, .booking-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.booking-chip strong { font-size: 0.75rem; }
.booking-chip span { color: var(--ink-soft); font-size: 0.66rem; }
.booking-chip.is-continuation { min-height: 2rem; justify-content: center; opacity: 0.78; }

.mobile-schedule { padding: 0.9rem; }
.mobile-empty { padding: 3rem 1rem; text-align: center; color: var(--ink-soft); }
.time-group { margin-bottom: 1rem; }
.time-label { margin: 0 0 0.45rem; color: var(--red); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.06em; }
.mobile-booking { width: 100%; min-height: 4.6rem; margin-bottom: 0.5rem; border: 1px solid var(--line); border-left: 0.3rem solid var(--ink); border-radius: 0.65rem; padding: 0.7rem; display: grid; grid-template-columns: 3.6rem minmax(0, 1fr) auto; align-items: center; gap: 0.7rem; color: var(--ink); background: var(--paper-light); text-align: left; }
.mobile-booking.is-own { border-left-color: var(--green); background: #f4faf7; }
.room-badge { font-family: "Noto Serif TC", serif; font-size: 1.05rem; font-weight: 900; }
.mobile-booking-copy { min-width: 0; }
.mobile-booking-copy strong, .mobile-booking-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-booking-copy span { color: var(--ink-soft); font-size: 0.82rem; }
.count-badge { min-width: 2.6rem; padding: 0.25rem 0.45rem; border-radius: 999px; color: var(--ink-soft); background: var(--blue-pale); font-size: 0.75rem; text-align: center; }

.site-footer { padding: 1.2rem 1rem 2rem; display: flex; flex-direction: column; gap: 0.35rem; color: var(--ink-soft); font-size: 0.75rem; text-align: center; }

.dialog { width: min(calc(100% - 1.25rem), 46rem); max-height: calc(100dvh - 1.25rem); padding: 0; border: 1px solid var(--line); border-radius: 1rem; color: var(--ink); background: var(--paper-light); box-shadow: 0 2rem 6rem rgba(14,30,45,.32); }
.dialog::backdrop { background: rgba(14, 30, 45, 0.58); backdrop-filter: blur(3px); }
.dialog-form { padding: 1.2rem; }
.dialog-header { margin-bottom: 1.2rem; display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
.dialog-header h2 { margin: 0; font-size: 1.65rem; }
.icon-button { width: 2.75rem; height: 2.75rem; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: transparent; font-size: 1.6rem; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0.9rem; }
.form-grid label { color: var(--ink-soft); font-size: 0.82rem; font-weight: 700; }
.form-grid input, .form-grid select { width: 100%; min-height: 2.9rem; margin-top: 0.35rem; border: 1px solid var(--line-strong); border-radius: 0.55rem; padding: 0.65rem 0.75rem; color: var(--ink); background: #fffefb; }
.form-error { min-height: 1.5rem; margin: 0.8rem 0 0; color: var(--red); font-size: 0.85rem; font-weight: 700; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.65rem; }
.dialog-compact { width: min(calc(100% - 1.25rem), 30rem); }
.detail-card { padding: 1.25rem; }
.detail-card h2 { margin-bottom: 0.3rem; font-size: 1.6rem; }
.detail-meta { margin: 1rem 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.65rem; }
.detail-meta div { padding: 0.65rem; border-radius: 0.55rem; background: #eee8dc; }
.detail-meta small, .detail-meta strong { display: block; }
.detail-meta small { color: var(--ink-soft); font-size: 0.72rem; }
.detail-owner { color: var(--ink-soft); font-size: 0.78rem; overflow-wrap: anywhere; }

.toast { position: fixed; left: 50%; bottom: 1.25rem; z-index: 60; width: max-content; max-width: calc(100% - 2rem); padding: 0.75rem 1rem; border-radius: 999px; color: white; background: var(--ink); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 1rem); transition: 180ms ease; text-align: center; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--red-dark); }

@media (min-width: 640px) {
  .login-row { grid-template-columns: minmax(0, 1fr) auto; }
  .user-chip { display: flex; }
  .demo-banner { flex-direction: row; justify-content: center; gap: 0.65rem; }
  .hero-actions { grid-template-columns: auto auto; justify-content: start; }
  .day-tabs { grid-template-columns: repeat(6, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .field-wide { grid-column: 1 / -1; }
  .site-footer { flex-direction: row; justify-content: space-between; text-align: left; }
}

@media (min-width: 768px) {
  .site-header { padding-inline: 1.5rem; }
  .main-content { padding: 2.2rem 1.5rem 4rem; }
  .hero-row { flex-direction: row; justify-content: space-between; align-items: flex-end; }
  .schedule-toolbar { padding: 1.25rem 1.5rem; flex-direction: row; align-items: end; justify-content: space-between; }
  .desktop-schedule { display: block; }
  .mobile-schedule { display: none; }
  .dialog-form { padding: 1.6rem; }
}

@media (min-width: 1024px) {
  .login-view { grid-template-columns: minmax(0, 2fr) minmax(19rem, 0.78fr); }
  .login-aside { padding: 4rem 2.5rem; display: grid; grid-template-columns: auto 1fr; align-content: center; gap: 1.4rem 1rem; color: white; background: var(--ink); }
  .login-aside p { margin: 0; align-self: center; font-family: "Noto Serif TC", serif; font-size: 1.2rem; }
  .feature-number { color: var(--gold); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; }
  .main-content { padding-inline: 2.5rem; }
}

@media print {
  @page { size: A3 landscape; margin: 8mm; }
  :root, body { background: white; color: black; }
  .paper-grain, .site-header, .demo-banner, .hero-actions, .legend, .day-tabs, .mobile-schedule, .site-footer, .toast, dialog { display: none !important; }
  .main-content { max-width: none; padding: 0; }
  .hero-row { margin: 0 0 4mm; display: block; }
  .hero-row h1 { margin: 0; font-size: 18pt; }
  .hero-copy { font-size: 9pt; }
  .schedule-card { border: 0; border-radius: 0; box-shadow: none; background: white; overflow: visible; }
  .schedule-toolbar { padding: 0 0 3mm; border: 0; }
  .schedule-toolbar h2::after { content: "｜目前星期"; }
  .desktop-schedule { display: block !important; overflow: visible; }
  .schedule-table { min-width: 0; table-layout: fixed; font-size: 7pt; }
  .schedule-table thead th { height: 8mm; position: static; background: #eee !important; print-color-adjust: exact; }
  .schedule-table .time-head, .schedule-table .time-cell { width: 16mm; position: static; background: #eee !important; print-color-adjust: exact; }
  .schedule-cell { height: 11mm; padding: 1mm; }
  .booking-chip { min-height: 9mm; padding: 1mm; border-radius: 1mm; background: #e6eef2 !important; print-color-adjust: exact; }
  .booking-chip.is-own { background: #deebe5 !important; }
  .booking-chip strong { font-size: 6.5pt; }
  .booking-chip span { font-size: 5.5pt; }
}

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