:root {
  --ink: #1c2b25;
  --paper: #eef0ea;
  --paper-raised: #f8f9f4;
  --board: #24463b;
  --board-deep: #1a352c;
  --chalk: #f4efd9;
  --accent: #dfa63f;
  --accent-deep: #b9821f;
  --line: #d7d4c3;
  --muted: #5c665e;
  --tc-color: #7a8f5f;
  --nn2-color: #7196a8;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header / chalkboard band ---------- */

.board {
  background: var(--board);
  background-image:
    radial-gradient(rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 3px 3px;
  color: var(--chalk);
  border-bottom: 6px solid var(--board-deep);
}

.board-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 30px 20px 22px;
}

.board-title {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.chalk-mark {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.14em;
  border: 1.5px solid var(--chalk);
  border-radius: 3px;
  padding: 3px 7px;
  opacity: 0.85;
}

.board-title h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 34px;
  margin: 0;
  letter-spacing: 0.01em;
}

.board-sub {
  margin: 8px 0 0;
  font-size: 14.5px;
  color: rgba(244,239,217,0.72);
}

.visit-count {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.visit-count:empty {
  display: none;
}

.version-switch {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.version-btn {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--chalk);
  background: rgba(244,239,217,0.08);
  border: 1.5px solid rgba(244,239,217,0.35);
  border-radius: 20px;
  padding: 7px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
}

.version-btn:hover { background: rgba(244,239,217,0.16); }

.version-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #2a1c04;
}

.version-btn .draft-flag {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(0,0,0,0.18);
  border-radius: 10px;
  padding: 1px 6px;
}

.version-btn.active .draft-flag {
  background: rgba(0,0,0,0.15);
}

/* ---------- Main layout ---------- */

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 22px 20px 60px;
  width: 100%;
  flex: 1;
}

/* ---------- Tabs (folder-tab style) ---------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 20px;
}

.tab {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(28,43,37,0.05);
  border: 2px solid var(--ink);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 9px 18px;
  cursor: pointer;
  position: relative;
  top: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab:hover { background: rgba(28,43,37,0.1); }

.tab.active {
  background: var(--paper-raised);
  color: var(--ink);
  top: 0;
  padding-top: 11px;
  border-bottom: 2px solid var(--paper-raised);
}

/* ---------- Picker row ---------- */

.picker-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.picker {
  flex: 1 1 280px;
  min-width: 220px;
}

.picker.hidden { display: none; }

.picker label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 6px;
}

.picker label .hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  opacity: 0.75;
}

select, input[type="text"] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15.5px;
  padding: 10px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: var(--paper-raised);
  color: var(--ink);
}

select:focus, input[type="text"]:focus {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

.combo { position: relative; }

.combo-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--paper-raised);
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  max-height: 260px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 6px 0 rgba(28,43,37,0.08);
}

.combo-list.open { display: block; }

.combo-item {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 14.5px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.combo-item:last-child { border-bottom: none; }

.combo-item:hover, .combo-item.highlighted {
  background: rgba(223,166,63,0.22);
}

.combo-item .item-sub {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.print-btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14.5px;
  background: var(--accent);
  color: #2a1c04;
  border: 1.5px solid var(--accent-deep);
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  height: 42px;
}

.print-btn:hover { background: var(--accent-deep); color: var(--chalk); }

/* ---------- Result area ---------- */

.empty-state {
  color: var(--muted);
  font-size: 15px;
  padding: 40px 10px;
  text-align: center;
  border: 1.5px dashed var(--line);
  border-radius: 8px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 12px;
}

.result-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0;
}

.result-meta {
  color: var(--muted);
  font-size: 14px;
}

.tt-scroll {
  overflow-x: auto;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-raised);
}

table.tt {
  border-collapse: collapse;
  width: 100%;
  min-width: 720px;
  font-size: 13.5px;
}

table.tt th, table.tt td {
  border: 1px solid var(--line);
  padding: 7px 9px;
  vertical-align: top;
}

table.tt thead th {
  background: var(--board);
  color: var(--chalk);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 3;
}

table.tt thead th:first-child {
  z-index: 4;
}

table.tt th.today, table.tt td.today {
  background: rgba(223,166,63,0.14);
}

table.tt thead th.today { background: var(--accent-deep); }

table.tt td.period-col, table.tt th.corner {
  background: var(--paper);
  font-weight: 600;
  text-align: center;
  width: 64px;
  position: sticky;
  left: 0;
  z-index: 2;
}

.period-time {
  font-weight: 400;
  font-size: 10.5px;
  color: #c0392b;
  white-space: nowrap;
  margin-top: 2px;
}

tr.session-row td {
  background: var(--board-deep);
  color: var(--chalk);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 5px 9px;
  position: sticky;
  left: 0;
}

.cell-subject {
  font-weight: 600;
  color: var(--ink);
}

.cell-teacher, .cell-class {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 1px;
}

.cell-empty {
  color: var(--line);
}

td[data-type] .cell-subject::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  background: var(--type-color, var(--tc-color));
}

td[data-type="1"] .cell-subject::before { background: var(--tc-color); }
td[data-type="2"] .cell-subject::before { background: var(--nn2-color); }
td[data-type="3"] .cell-subject::before { background: #a0687a; }
td[data-type="4"] .cell-subject::before { background: #6f8fb0; }
td[data-type="5"] .cell-subject::before { background: #b08a4f; }

td.has-note {
  cursor: help;
}

.note-flag {
  color: var(--accent-deep);
  font-weight: 700;
}

/* ---------- Legend ---------- */

.legend {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 4px;
}

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: middle;
}
.dot-tc { background: var(--tc-color); }
.dot-nn2 { background: var(--nn2-color); }
.note-mark { color: var(--accent-deep); font-weight: 700; }

/* ---------- Footer ---------- */

footer {
  border-top: 1.5px solid var(--line);
  padding: 16px 20px 26px;
  text-align: center;
}

footer p {
  max-width: 700px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 12.5px;
}

.admin-link {
  color: var(--muted);
  opacity: 0.55;
  font-size: 11px;
  text-decoration: none;
}
.admin-link:hover { opacity: 1; text-decoration: underline; }

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
  .board-title h1 { font-size: 26px; }
  .board-inner { padding: 22px 16px 18px; }
  main { padding: 18px 12px 40px; }
  .tab { padding: 8px 12px; font-size: 14px; }
}

/* ---------- Print ---------- */

@media print {
  header.board, .tabs, .picker-row, .legend, footer, .print-btn, .version-switch { display: none !important; }
  body { background: #fff; }
  .tt-scroll { border: none; overflow: visible; }
  table.tt thead th { position: static; background: #e7e7e7 !important; color: #000 !important; }
  table.tt td.period-col { position: static; }
  tr.session-row td { position: static; background: #ddd !important; color: #000 !important; }
}
