:root {
  color-scheme: light;
  font-family: Pretendard, SUIT, "Noto Sans KR", system-ui, -apple-system, sans-serif;
  color: #171816;
  background: #f3f3ef;
  --accent: #315cf6;
  --accent-strong: #2448ca;
  --ink: #171816;
  --muted: #6d7069;
  --line: #d9dad3;
  --line-strong: #bfc1b8;
  --surface: #fbfbf8;
  --soft: #eeeeea;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #f3f3ef; }
body { min-width: 320px; margin: 0; background: #f3f3ef; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }

.app-shell { width: min(1160px, calc(100% - 40px)); margin-inline: auto; padding-bottom: 56px; }
.app-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; padding: 30px 0 21px; border-bottom: 1px solid var(--line-strong); }
.identity { min-width: 0; }
.title-line { display: flex; align-items: baseline; gap: 18px; }
h1 { font-size: clamp(1.55rem, 3.5vw, 2.35rem); font-weight: 740; letter-spacing: -.055em; }
h2 { font-size: 1.02rem; font-weight: 720; letter-spacing: -.035em; }
.section-label { margin-bottom: 6px; color: var(--muted); font-size: .68rem; font-weight: 760; letter-spacing: .045em; }
.live-clock { color: var(--ink); font-size: 1rem; font-variant-numeric: tabular-nums; font-weight: 670; letter-spacing: .025em; }
.connection-status { margin-top: 7px; color: var(--muted); font-size: .78rem; }
.connection-status.is-online::before, .connection-status.is-offline::before { display: inline-block; width: 6px; height: 6px; margin: 0 7px 1px 0; border-radius: 50%; content: ""; }
.connection-status.is-online::before { background: var(--accent); }
.connection-status.is-offline::before { background: #8b8d87; }
.header-actions { display: flex; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }

.button { display: inline-flex; min-height: 36px; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 5px; padding: .5rem .75rem; background: transparent; color: var(--ink); font-size: .78rem; font-weight: 680; line-height: 1; text-decoration: none; }
.button:hover { border-color: #858980; background: #e9e9e4; }
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button.primary:hover { border-color: var(--accent-strong); background: var(--accent-strong); }
.button.dark { border-color: var(--ink); background: var(--ink); color: #fff; }
.button.danger { border-color: #d6aaaa; color: #9d2929; }
.button:focus-visible, .icon-button:focus-visible, .schedule-card:focus-visible, .check-item:focus-visible, .task-main:focus-visible, .task-toggle:focus-visible, .task-delete:focus-visible {
  outline: 3px solid rgba(49, 92, 246, .34);
  outline-offset: 2px;
}

main { padding-top: 18px; }
.now-board { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(260px, .72fr); border: 1px solid var(--ink); background: var(--surface); }
.now-primary { min-height: 206px; padding: 28px 30px 24px; border-right: 1px solid var(--ink); }
.now-kicker { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--accent); font-size: .72rem; font-weight: 760; }
.now-kicker span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.now-title { max-width: 780px; margin-top: 24px; font-size: clamp(1.55rem, 4.2vw, 3.1rem); line-height: 1.08; letter-spacing: -.06em; }
.now-detail { min-height: 1.4em; margin-top: 9px; color: var(--muted); font-size: .86rem; line-height: 1.55; }
.progress-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; margin-top: 22px; }
.progress-track { height: 3px; background: #dfe0da; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .35s ease; }
.progress-label { color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums; }
.next-block { display: flex; min-width: 0; flex-direction: column; justify-content: center; padding: 26px; }
.next-title { overflow: hidden; font-size: 1.16rem; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.next-meta { margin-top: 8px; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.next-countdown { margin-top: 19px; color: var(--accent); font-size: .82rem; font-weight: 740; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .75fr); gap: 14px; margin-top: 14px; }
.section-surface { border: 1px solid var(--line); background: var(--surface); padding: 20px; }
.section-surface + .section-surface, .workspace-grid + .section-surface { margin-top: 14px; }
.workspace-grid > .section-surface { margin-top: 0; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading.compact { margin-bottom: 13px; }
.revision, .checklist-summary { color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

.timeline { position: relative; display: grid; }
.timeline-item { display: grid; grid-template-columns: 70px 18px minmax(0, 1fr); min-height: var(--timeline-height, 58px); }
.timeline-time { padding: 13px 10px 0 0; color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums; font-weight: 650; text-align: right; white-space: pre-line; }
.timeline-rail { position: relative; }
.timeline-rail::before { position: absolute; top: 0; bottom: 0; left: 8px; width: 1px; background: var(--line); content: ""; }
.timeline-dot { position: absolute; z-index: 1; top: 16px; left: 5px; width: 7px; height: 7px; border: 1px solid #a9aca4; border-radius: 50%; background: var(--surface); }
.timeline-item.is-current .timeline-dot, .timeline-item.is-next .timeline-dot { border-color: var(--accent); background: var(--accent); }
.schedule-card { width: 100%; min-width: 0; height: calc(100% - 6px); margin-bottom: 6px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 10px 4px 11px; background: transparent; color: var(--ink); text-align: left; }
.schedule-card:hover { background: var(--soft); }
.schedule-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; color: var(--muted); font-size: .64rem; }
.schedule-state { color: var(--muted); font-weight: 680; }
.is-current .schedule-state, .is-next .schedule-state { color: var(--accent); }
.schedule-title { display: block; overflow: hidden; font-size: .88rem; font-weight: 720; letter-spacing: -.025em; text-overflow: ellipsis; white-space: nowrap; }
.schedule-detail { display: -webkit-box; overflow: hidden; margin-top: 4px; color: var(--muted); font-size: .72rem; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.timeline-item.is-past, .timeline-item.is-completed { opacity: .47; }
.timeline-item.is-completed .schedule-title { text-decoration: line-through; }
.timeline-item.is-started .schedule-state { color: #765f27; }
.empty { padding: 22px 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: .8rem; text-align: center; }

.checklist { display: grid; }
.check-item { display: grid; grid-template-columns: 19px minmax(0, 1fr); gap: 10px; width: 100%; align-items: center; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 11px 2px; background: transparent; color: #33352f; text-align: left; font-size: .8rem; }
.check-item:last-child { border-bottom: 1px solid var(--line); }
.check-item:hover { background: var(--soft); }
.check-mark { display: grid; width: 17px; height: 17px; place-items: center; border: 1px solid #9da098; border-radius: 2px; color: transparent; font-size: .68rem; font-weight: 800; }
.check-item[aria-pressed="true"] { color: var(--muted); text-decoration: line-through; }
.check-item[aria-pressed="true"] .check-mark { border-color: var(--accent); background: var(--accent); color: #fff; }

.quick-form { display: grid; grid-template-columns: minmax(190px, 1.6fr) 150px 110px 120px auto; gap: 9px; align-items: end; }
label { display: grid; gap: 5px; color: var(--muted); font-size: .72rem; font-weight: 660; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 4px; padding: .61rem .65rem; background: #fff; color: var(--ink); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid rgba(49, 92, 246, .2); }
.task-list { display: grid; margin-top: 16px; border-top: 1px solid var(--line); }
.task-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.task-row.is-complete { color: var(--muted); }
.task-row.is-complete .task-main { color: var(--muted); text-decoration: line-through; }
.task-main { overflow: hidden; width: 100%; border: 0; padding: 0; background: transparent; color: var(--ink); font-size: .8rem; font-weight: 680; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.task-meta { margin-top: 3px; color: var(--muted); font-size: .67rem; }
.task-toggle { display: grid; width: 19px; height: 19px; place-items: center; border: 1px solid #9da098; border-radius: 2px; background: #fff; color: #fff; font-size: .68rem; }
.task-row.is-complete .task-toggle { border-color: var(--accent); background: var(--accent); }
.task-delete { border: 0; padding: 4px; background: transparent; color: #9d2929; font-size: .7rem; }

.weekly-scroll { overflow-x: auto; border: 1px solid var(--line); }
table { width: 100%; min-width: 780px; border-collapse: collapse; table-layout: fixed; }
th, td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 7px; vertical-align: top; }
th:last-child, td:last-child { border-right: 0; }
tr:last-child td { border-bottom: 0; }
th { background: #232421; color: #fff; font-size: .7rem; font-weight: 650; }
th:first-child { width: 90px; }
td.time-cell { background: #efefeb; color: var(--muted); font-size: .68rem; font-variant-numeric: tabular-nums; font-weight: 650; text-align: center; vertical-align: middle; }
td.today-column { background: rgba(49, 92, 246, .055); }
.weekly-scroll .schedule-card { min-height: 56px; padding: 7px 5px; }
.weekly-scroll .schedule-title { font-size: .73rem; white-space: normal; }
.weekly-scroll .schedule-detail { font-size: .64rem; -webkit-line-clamp: 1; }
.help, .dialog-copy { margin-top: 13px; color: var(--muted); font-size: .75rem; line-height: 1.55; }

dialog { width: min(460px, calc(100% - 28px)); border: 1px solid var(--ink); border-radius: 6px; padding: 0; background: var(--surface); box-shadow: 0 22px 64px rgba(24, 25, 22, .25); }
dialog::backdrop { background: rgba(23, 24, 22, .48); }
.dialog-form { display: grid; gap: 14px; padding: 22px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; }
.icon-button { border: 0; padding: 2px 7px; background: transparent; color: var(--muted); font-size: 1.45rem; line-height: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.checkbox-line { display: flex; align-items: center; gap: 8px; }
.checkbox-line input { width: auto; }
.dialog-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.error { min-height: 1.15em; color: #9d2929; font-size: .76rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

body.widget-mode { min-width: 300px; background: rgba(243, 243, 239, .94); }
.widget-mode .app-shell { width: min(100%, 380px); padding: 0 12px 16px; }
.widget-mode .app-header { display: block; padding: 14px 0 11px; }
.widget-mode .section-label { font-size: .61rem; }
.widget-mode .title-line { justify-content: space-between; gap: 10px; }
.widget-mode h1 { font-size: 1.1rem; letter-spacing: -.04em; }
.widget-mode .live-clock { font-size: .9rem; }
.widget-mode .connection-status { margin-top: 4px; font-size: .67rem; }
.widget-mode .header-actions { justify-content: flex-start; margin-top: 10px; }
.widget-mode .button { min-height: 31px; padding: .42rem .58rem; font-size: .68rem; }
.widget-mode #logout-button { display: none; }
.widget-mode main { padding-top: 10px; }
.widget-mode .now-board { grid-template-columns: 1fr; }
.widget-mode .now-primary { min-height: 151px; padding: 17px; border-right: 0; border-bottom: 1px solid var(--ink); }
.widget-mode .now-title { margin-top: 16px; font-size: 1.42rem; line-height: 1.13; }
.widget-mode .now-detail { margin-top: 6px; font-size: .72rem; }
.widget-mode .progress-wrap { margin-top: 15px; }
.widget-mode .next-block { min-height: 102px; padding: 15px 17px; }
.widget-mode .next-title { font-size: .94rem; }
.widget-mode .next-meta { margin-top: 5px; font-size: .68rem; }
.widget-mode .next-countdown { margin-top: 10px; font-size: .72rem; }
.widget-mode .workspace-grid { grid-template-columns: 1fr; gap: 10px; margin-top: 10px; }
.widget-mode .section-surface { padding: 14px; }
.widget-mode .workspace-grid > .section-surface + .section-surface { margin-top: 0; }
.widget-mode .section-heading { margin-bottom: 11px; }
.widget-mode .timeline-item { grid-template-columns: 59px 16px minmax(0, 1fr); min-height: min(var(--timeline-height, 54px), 78px); }
.widget-mode .timeline-time { padding-right: 7px; font-size: .62rem; }
.widget-mode .schedule-card { padding-top: 9px; }
.widget-mode .schedule-title { font-size: .78rem; }
.widget-mode .schedule-detail { display: none; }
.widget-mode .schedule-meta { font-size: .58rem; }
.widget-mode .check-item { padding: 9px 1px; font-size: .73rem; }
.widget-mode .planner-only { display: none; }

@media (max-width: 780px) {
  .app-shell { width: min(100% - 24px, 660px); }
  .app-header { display: block; padding-top: 20px; }
  .header-actions { justify-content: flex-start; margin-top: 14px; }
  .now-board { grid-template-columns: 1fr; }
  .now-primary { border-right: 0; border-bottom: 1px solid var(--ink); }
  .workspace-grid { grid-template-columns: 1fr; }
  .quick-form { grid-template-columns: 1fr 1fr; }
  .quick-form label:first-child { grid-column: 1 / -1; }
  .quick-form .button { grid-column: 1 / -1; }
}

@media (max-width: 440px) {
  .title-line { align-items: flex-start; flex-direction: column; gap: 4px; }
  .now-primary { min-height: 180px; padding: 21px 19px; }
  .now-title { font-size: 1.65rem; }
  .next-block { padding: 20px; }
  .section-surface { padding: 15px; }
  .form-grid { grid-template-columns: 1fr; }
  .timeline-item { grid-template-columns: 61px 16px minmax(0, 1fr); }
  .timeline-time { padding-right: 7px; font-size: .63rem; }
}

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