:root {
  --bg: #f3efe7;
  --paper: rgba(255, 251, 246, 0.94);
  --paper-strong: #fffaf5;
  --ink: #1f2933;
  --muted: #5f6d79;
  --line: rgba(31, 41, 51, 0.12);
  --brand: #bf5a2f;
  --brand-dark: #8f3f22;
  --accent: #1e6f64;
  --accent-soft: rgba(30, 111, 100, 0.1);
  --warning: #9b5a16;
  --danger: #9d3c31;
  --shadow: 0 22px 60px rgba(31, 41, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(191, 90, 47, 0.15), transparent 32%),
    radial-gradient(circle at top right, rgba(30, 111, 100, 0.12), transparent 28%),
    linear-gradient(180deg, #f8f2ea 0%, #ede4d6 100%);
}

.access-check-pending .page-shell,
.access-check-pending .access-gate {
  display: none;
}

code {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(30, 111, 100, 0.1);
  color: var(--accent);
  font-family: "SFMono-Regular", "Menlo", "Monaco", monospace;
  font-size: 0.92em;
}

.page-shell {
  width: min(1460px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 30px 0 48px;
}

.mode-topbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
  padding: 18px 22px;
  background: rgba(255, 251, 246, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 22px;
  box-shadow: 0 12px 30px rgba(31, 41, 51, 0.08);
  backdrop-filter: blur(10px);
}

.mode-topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.mode-title-group {
  min-width: 0;
}

.mode-topbar-title {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Songti SC", serif;
  font-size: 24px;
  line-height: 1.15;
}

.mode-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.mode-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  line-height: 1.5;
}

.access-gate {
  width: min(780px, calc(100vw - 32px));
  margin: 48px auto;
}

.access-gate-card {
  background: rgba(255, 250, 244, 0.96);
  border: 1px solid rgba(157, 60, 49, 0.14);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 30px;
}

.access-gate-title {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Songti SC", serif;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.access-gate-text {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.access-gate-list {
  margin: 18px 0 0;
  padding-left: 20px;
  color: var(--ink);
  line-height: 1.8;
}

.access-gate-detail {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(30, 111, 100, 0.08);
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.hero,
.panel {
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
  border-radius: 28px;
  backdrop-filter: blur(10px);
}

.hero {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr;
  gap: 24px;
  padding: 32px;
}

.hero-copy h1,
.panel-header h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Songti SC", serif;
  letter-spacing: -0.02em;
}

.hero-copy h1 {
  font-size: clamp(32px, 4vw, 50px);
  line-height: 1.04;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand);
}

.hero-text,
.panel-header p,
.tool-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.button,
.text-link {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.button:hover,
.text-link:hover {
  transform: translateY(-1px);
}

.button-block {
  width: 100%;
}

.button-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  box-shadow: 0 16px 28px rgba(143, 63, 34, 0.22);
}

.button-secondary {
  background: linear-gradient(135deg, #18443d 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: 0 16px 28px rgba(30, 111, 100, 0.2);
}

.button-ghost {
  background: var(--paper-strong);
  color: var(--ink);
  border: 1px solid var(--line);
}

.button-ghost.is-active {
  background: rgba(191, 90, 47, 0.14);
  border-color: rgba(191, 90, 47, 0.24);
  color: var(--brand-dark);
}

.text-link {
  display: inline-flex;
  align-items: center;
  color: var(--brand-dark);
  padding: 0;
}

.simple-only {
  display: none;
}

.simple-guide {
  background:
    linear-gradient(180deg, rgba(255, 247, 238, 0.96), rgba(244, 252, 250, 0.94)),
    var(--paper);
}

.simple-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.simple-step-card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 20px;
  padding: 16px;
}

.simple-step-card strong {
  display: block;
  line-height: 1.5;
}

.simple-step-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 22px 0;
}

.metric-card {
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 14px 28px rgba(31, 41, 51, 0.08);
}

.metric-card.is-warning {
  background: rgba(255, 244, 230, 0.86);
  border-color: rgba(191, 90, 47, 0.24);
}

.metric-label {
  font-size: 13px;
  color: var(--muted);
}

.metric-value {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 700;
}

.metric-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.panel {
  padding: 24px;
  margin-top: 18px;
}

.panel-tools {
  background:
    linear-gradient(180deg, rgba(244, 252, 250, 0.94), rgba(255, 249, 242, 0.94)),
    var(--paper);
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

.tool-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 22px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tool-card h3 {
  margin: 0;
  font-size: 20px;
}

.tool-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tool-action-row .button {
  flex: 1 1 180px;
}

.tool-inline-note {
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(30, 111, 100, 0.12);
  color: var(--muted);
  line-height: 1.5;
}

.backend-connection-status,
.save-status {
  min-height: 40px;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-all;
}

.import-log {
  min-height: 110px;
  white-space: pre-wrap;
  color: var(--ink);
}

.question-card {
  padding: 12px 0 14px;
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
}

.question-summary {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(191, 90, 47, 0.08);
  border: 1px solid rgba(191, 90, 47, 0.14);
  color: var(--ink);
  line-height: 1.6;
}

.question-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.question-card:last-child {
  border-bottom: 0;
}

.question-title {
  margin-bottom: 10px;
  font-weight: 600;
  color: var(--danger);
}

.question-source {
  margin-top: -4px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.question-suggestion-note {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 12px;
  line-height: 1.5;
}

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

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

.question-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.question-field.is-wide {
  grid-column: 1 / -1;
}

.question-field.is-focus .cell-input {
  border-color: rgba(191, 90, 47, 0.45);
  background: rgba(255, 247, 242, 0.96);
  box-shadow: inset 0 0 0 1px rgba(191, 90, 47, 0.08);
}

.question-field-suggestion {
  margin-top: 8px;
  appearance: none;
  border: 1px solid rgba(30, 111, 100, 0.18);
  border-radius: 999px;
  background: rgba(30, 111, 100, 0.08);
  color: var(--accent);
  padding: 8px 12px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.question-candidate-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.question-candidate-chip {
  appearance: none;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

.question-apply-button {
  padding: 10px 14px;
}

.import-question-actions {
  margin-top: 12px;
}

.question-remove-button {
  flex: 0 0 auto;
  padding: 10px 14px;
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.cell-input,
.cell-select {
  width: 100%;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 12px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.cell-input:focus,
.cell-select:focus {
  outline: 2px solid rgba(191, 90, 47, 0.18);
  border-color: rgba(191, 90, 47, 0.35);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-hint {
  margin-top: 14px;
}

.filter-hint.is-warning {
  background: rgba(255, 244, 230, 0.92);
  border-color: rgba(191, 90, 47, 0.24);
  color: #8c3f24;
}

.simple-card-list {
  display: none;
  gap: 14px;
}

.simple-edit-card {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 12px 24px rgba(31, 41, 51, 0.08);
}

.simple-edit-card.is-invalid {
  background: rgba(255, 248, 238, 0.96);
  border-color: rgba(191, 90, 47, 0.22);
}

.simple-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.simple-card-title {
  min-width: 0;
}

.simple-card-title strong {
  display: block;
  line-height: 1.45;
}

.simple-card-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.simple-card-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.simple-card-field.is-wide {
  grid-column: 1 / -1;
}

.simple-card-field .field-label {
  margin: 0;
}

.simple-remove-button {
  appearance: none;
  border: 1px solid rgba(157, 60, 49, 0.18);
  background: rgba(157, 60, 49, 0.08);
  color: var(--danger);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.simple-mode .simple-only {
  display: inline-flex;
}

.simple-mode .simple-guide.simple-only {
  display: block;
}

.simple-mode .simple-card-list.simple-only {
  display: grid;
}

.simple-mode .advanced-only {
  display: none !important;
}

.simple-mode .hero-actions .button {
  font-weight: 600;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.calendar-cell {
  min-height: 160px;
  padding: 12px;
  border-radius: 20px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: rgba(255, 255, 255, 0.72);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calendar-weekday {
  min-height: 0;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.45);
}

.calendar-cell.is-empty {
  background: rgba(255, 255, 255, 0.36);
}

.calendar-day-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.calendar-day-meta {
  font-size: 12px;
  color: var(--muted);
}

.entry-chip-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-chip {
  border-radius: 16px;
  padding: 10px 11px;
  background: rgba(191, 90, 47, 0.08);
  border: 1px solid rgba(191, 90, 47, 0.12);
}

.entry-chip.pending {
  background: rgba(155, 90, 22, 0.1);
  border-color: rgba(155, 90, 22, 0.18);
}

.entry-chip.adjusted,
.entry-chip.makeup {
  background: rgba(30, 111, 100, 0.1);
  border-color: rgba(30, 111, 100, 0.18);
}

.entry-chip-title {
  font-weight: 700;
  line-height: 1.4;
}

.entry-chip-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.room-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.room-card {
  border-radius: 22px;
  padding: 16px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: rgba(255, 255, 255, 0.72);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.room-card h3 {
  margin: 0;
  font-size: 18px;
}

.room-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.empty-state {
  color: var(--muted);
}

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.data-table tr.is-invalid td {
  background: rgba(255, 248, 238, 0.92);
}

.cell-warning {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: #a14b27;
}

.mini-button {
  appearance: none;
  border: 1px solid rgba(157, 60, 49, 0.18);
  background: rgba(157, 60, 49, 0.08);
  color: var(--danger);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

@media (max-width: 1180px) {
  .mode-topbar-main,
  .hero {
    grid-template-columns: 1fr;
  }

  .mode-nav {
    justify-content: flex-start;
  }

  .tool-grid,
  .filter-grid,
  .simple-steps {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100vw, calc(100vw - 20px));
  }

  .mode-topbar {
    padding: 16px;
  }

  .mode-topbar-title {
    font-size: 21px;
  }

  .hero,
  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .tool-grid,
  .filter-grid,
  .simple-card-grid,
  .calendar-grid,
  .simple-steps {
    grid-template-columns: 1fr;
  }

  .question-header {
    flex-direction: column;
    align-items: stretch;
  }

  .question-header-actions {
    justify-content: flex-start;
  }

  .calendar-cell {
    min-height: 0;
  }
}
