:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e3e6eb;
  --border-strong: #c9cfd8;
  --text: #16181d;
  --muted: #5b6470;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.09);
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 18, 21, 0.05);
  --header-h: 58px;
}

html.dark {
  --bg: #101114;
  --surface: #1a1c20;
  --border: #2a2d33;
  --border-strong: #3a3f47;
  --text: #e8eaed;
  --muted: #9aa3af;
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    'Noto Sans SC', 'Noto Sans TC', 'Noto Sans KR', 'Noto Sans', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 28px;
  height: 28px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--bg);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.lang-select {
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
}

.lang-select:focus,
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Layout ---------- */

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 36px 20px 48px;
  flex: 1;
}

.hero {
  text-align: center;
  padding: 18px 0 30px;
}

.hero h1 {
  font-size: clamp(26px, 4.4vw, 38px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  max-width: 620px;
  margin: 0 auto;
}

.hero-sub {
  color: var(--muted);
  font-size: 16px;
  max-width: 560px;
  margin: 14px auto 0;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

/* ---------- Form ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
  flex: 1;
  min-width: 0;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
  min-width: 0;
}

@media (max-width: 480px) {
  .field-row {
    flex-direction: column;
    gap: 0;
  }
}

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

.field input,
.field select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  transition: border-color 0.15s;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.swatches {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
  min-height: 38px;
  padding-top: 2px;
}

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s, border-color 0.12s;
}

.swatch:hover {
  transform: scale(1.12);
}

.swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface) inset;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.panel-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 600;
  font-family: inherit;
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  box-shadow: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--border-strong);
  background: var(--bg);
}

.btn-lg {
  padding: 12px 22px;
  font-size: 15.5px;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
}

.btn.danger {
  color: var(--danger);
}

.btn.danger:hover {
  border-color: var(--danger);
  background: rgba(220, 38, 38, 0.06);
}

/* ---------- Timetable ---------- */

.schedule-panel {
  min-width: 0;
}

.schedule-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.schedule-head h2 {
  margin-bottom: 0;
}

.start-date {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.start-date label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}

.start-date input {
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}

.start-date input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.timetable {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.tt-header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--header-h);
  z-index: 2;
  background: var(--surface);
}

.tt-dayhead {
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 2px;
}

.tt-dayhead.today {
  color: var(--accent);
}

.tt-body {
  display: contents;
}

.tt-gutter {
  position: relative;
}

.tt-hour {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tt-col {
  position: relative;
  border-left: 1px solid var(--border);
  background-image: linear-gradient(
    to bottom,
    var(--border) 1px,
    transparent 1px
  );
  background-size: 100% 56px;
  cursor: crosshair;
}

.tt-col.drop-day {
  background-color: var(--accent-soft);
}

.tt-col:not(.has-course):hover::after {
  content: '+';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  font-weight: 300;
  color: var(--muted);
  opacity: 0.55;
  pointer-events: none;
}

@media (max-width: 760px) {
  .timetable {
    min-width: 720px;
  }
  .schedule-panel {
    overflow-x: auto;
  }
}

.course-block {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 8px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 5px 8px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: pan-y;
  transition: filter 0.12s, transform 0.12s;
  min-height: 30px;
}

.course-block.dragging {
  opacity: 0.35;
  transition: none;
}

.course-block:hover {
  filter: brightness(0.96);
}

html.dark .course-block:hover {
  filter: brightness(1.25);
}

.course-block .cb-name {
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-block .cb-time,
.course-block .cb-loc {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-block .cb-del {
  position: absolute;
  top: 2px;
  right: 3px;
  width: 17px;
  height: 17px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.course-block:hover .cb-del {
  display: inline-flex;
}

.course-block .cb-del:hover {
  background: rgba(0, 0, 0, 0.12);
  color: var(--text);
}

.empty-state {
  text-align: center;
  padding: 34px 10px 26px;
  color: var(--muted);
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.empty-sub {
  font-size: 13.5px;
  margin-top: 4px;
}

/* ---------- Timetable interactions ---------- */

.schedule-panel {
  position: relative;
}

.drag-ghost {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 8px 20px -8px rgba(16, 18, 21, 0.28);
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

.block-tip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 10px 30px -12px rgba(16, 18, 21, 0.3);
  padding: 10px 12px;
  min-width: 200px;
  max-width: 280px;
  font-size: 12.5px;
}

.block-tip .tip-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: -0.01em;
}

.block-tip .tip-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.block-tip .tip-row {
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.45;
}

.quick-add {
  position: absolute;
  z-index: 40;
  width: 230px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 32px -12px rgba(16, 18, 21, 0.32);
  padding: 10px;
}

.quick-add .qa-head {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 7px;
}

.quick-add input {
  width: 100%;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}

.quick-add input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.quick-add .qa-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ---------- Export ---------- */

.export-panel {
  margin-top: 20px;
}

.export-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.export-copy p {
  color: var(--muted);
  font-size: 14px;
  max-width: 560px;
  margin-top: 4px;
}

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

.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-body {
  padding: 16px 2px 4px;
  font-size: 14px;
}

.tab-body ol,
.tab-body ul,
.tips ul {
  padding-left: 20px;
  color: var(--text);
}

.tab-body li,
.tips li {
  margin-bottom: 8px;
}

.tips {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.tips summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.tips ul {
  margin-top: 10px;
  font-size: 13.5px;
}

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

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.footer-credit a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-credit a:hover {
  color: var(--accent);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(16, 18, 21, 0.18);
  z-index: 50;
  max-width: min(92vw, 480px);
  text-align: center;
}

html.dark .toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

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

