:root {
  color-scheme: light;
  --paper: #fff8ec;
  --surface: #fffdfa;
  --ink: #38261b;
  --muted: #795b48;
  --line: #ead7bc;
  --honey: #ffe6ab;
  --amber: #f9ba57;
  --rust: #8d3f16;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; background: radial-gradient(ellipse at 76% 0%, #ffedce, transparent 52rem); }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--rust); outline-offset: 3px; }
svg { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

.app-header { border-bottom: 1px solid var(--line); }
.header-inner {
  max-width: 1056px;
  min-height: 76px;
  margin: auto;
  padding: 10px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.brand { grid-column: 1; grid-row: 1; display: flex; align-items: center; gap: 10px; font-weight: 750; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 14px; background: var(--honey); color: var(--rust); }
#settings { grid-column: 3; grid-row: 1; justify-self: end; }
.main-nav { grid-column: 2; display: flex; gap: 4px; }
.main-nav button, .view-selector button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 16px;
  border: 0;
  border-radius: 100px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  white-space: nowrap;
}
.main-nav button[aria-current="page"], .view-selector button[aria-pressed="true"] { background: var(--honey); color: #663314; }
.badge { min-width: 1.35em; padding: 0 4px; border-radius: 20px; background: var(--rust); color: white; font-size: .72rem; }

.app-shell { max-width: 1056px; margin: auto; padding: clamp(24px, 5vw, 64px) 24px 48px; }
.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.58fr) minmax(0, 1fr);
  grid-template-areas: "video heading" "video actions";
  grid-template-rows: auto 1fr;
  column-gap: clamp(26px, 5vw, 62px);
  row-gap: 24px;
  align-items: start;
}
.scene-heading { grid-area: heading; margin-top: clamp(12px, 4vw, 40px); }
.view-selector { display: inline-flex; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 100px; background: var(--surface); }
.view-selector button { min-width: 76px; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.3; font-weight: 750; }
.scene-heading h1 { margin-top: 16px; }
.scene-fallback { display: inline-block; margin-top: 8px; color: var(--muted); font-size: .84rem; }
.scene-frame {
  grid-area: video;
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: #f9e5c6;
  box-shadow: 0 12px 38px #7d3c1312;
}
.scene-frame video { display: block; width: 100%; height: 100%; object-fit: contain; }
.scene-empty { display: grid; place-content: center; justify-items: center; gap: 10px; height: 100%; color: var(--muted); }
.scene-empty svg { width: 28px; height: 28px; }
.scene-frame video { cursor: pointer; }
.scene-frame video:focus-visible { outline-offset: -4px; }


.quick-actions { grid-area: actions; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-actions button {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  min-height: 78px;
  padding: 9px 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  font-size: .9rem;
  font-weight: 650;
}
.quick-actions svg { color: var(--rust); }
.quick-actions button:disabled { background: #fff0d3; color: var(--muted); }

.login-card, .secondary-view { max-width: 670px; margin: 0 auto; }
.login-card {
  max-width: 400px;
  padding: clamp(20px, 5vw, 38px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 12px 38px #7d3c130c;
}
.login-card h1 { margin-bottom: 20px; }
.login-card .primary-button { width: 100%; }
details { margin-top: 18px; font-size: .82rem; color: var(--muted); }
summary { cursor: pointer; }

.role-chip, .primary-button {
  min-height: 44px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: .9rem;
  font-weight: 650;
}
.primary-button { border-color: #eca847; background: var(--amber); }
form .primary-button { margin-top: 16px; }
form button + button { margin-top: 8px; }
.primary-button:disabled { opacity: .6; }
@media (hover: hover) {
  .role-chip:hover, .quick-actions button:not(:disabled):hover, .view-selector button:hover, .main-nav button:hover { background: #ffedc9; }
  .primary-button:not(:disabled):hover { background: #ffc46c; }
}

.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
#calendar-view > h1 { margin-bottom: 18px; }
.toolbar-actions { display: flex; gap: 8px; }
label { display: block; margin: 14px 0 5px; font-size: .9rem; font-weight: 650; }
.text-field {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
#day { width: auto; max-width: 100%; }
textarea.text-field { min-height: 96px; resize: vertical; }
input[type="checkbox"] { accent-color: var(--rust); }
input[type="file"] { width: 100%; color: var(--muted); }
.muted { color: var(--muted); font-size: .88rem; }

.stack { display: grid; gap: 10px; margin-top: 18px; }
.event-card, .notice-card { min-width: 0; padding: 13px 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); overflow-wrap: anywhere; }
.event-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.event-card h3 { font-size: 1rem; }
.event-card button { flex: none; }
.event-card.is-active, .notice-card.is-unread { border-color: #e8bb7c; background: #fff0d5; }
.notice-card p { white-space: pre-wrap; }
.notice-card small { color: var(--muted); }
.stack > .muted { padding: 14px 0; }

.room-dialog {
  width: min(440px, calc(100% - 24px));
  max-height: 90dvh;
  padding: 20px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
}
.room-dialog::backdrop { background: #3322176b; }
.sheet-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sheet-heading h2 { font-size: 1.2rem; }
.sheet-heading button { flex: none; }
#sheet-error, .form-error { color: #9b2c18; font-size: .88rem; }
#sheet-error:not(:empty), .form-error:not(:empty) { margin-top: 8px; }
#message {
  position: fixed;
  z-index: 2;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 90vw;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: white;
}

@media (max-width: 680px) {
  .header-inner { grid-template-columns: 1fr auto; min-height: 64px; padding-inline: 16px; }
  #settings { grid-column: 2; }
  .main-nav {
    position: fixed;
    z-index: 1;
    inset: auto 0 0;
    justify-content: center;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--paper);
  }
  .main-nav button { flex: 1; max-width: 132px; }
  .app-shell { padding: 20px 16px calc(88px + env(safe-area-inset-bottom)); }
  .home-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "heading" "video" "actions"; grid-template-rows: auto; row-gap: 12px; }
  .scene-heading { margin: 0; }
  .scene-heading h1 { margin-top: 10px; font-size: 1.32rem; }
  .scene-frame { border-radius: 20px; }
  .quick-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
  .quick-actions button { min-height: 64px; border-radius: 12px; gap: 4px; font-size: .78rem; }
  .quick-actions svg { width: 20px; height: 20px; }
  #message { bottom: calc(74px + env(safe-area-inset-bottom)); }
}
