:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #eef0ed;
  --text: #1c2321;
  --muted: #5d6965;
  --border: #d9ded9;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --work: #15803d;
  --off: #c2410c;
  --unclear: #8a948f;
  --break: #4f6fd8;
  --warn-bg: #fff1e6;
  --warn-border: #f0a36b;
  --danger: #b42318;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615;
    --surface: #1a1f1e;
    --surface-2: #232927;
    --text: #e8ece9;
    --muted: #9aa6a1;
    --border: #2f3835;
    --accent: #2dd4bf;
    --accent-text: #0b1210;
    --work: #4ade80;
    --off: #fb923c;
    --unclear: #78847f;
    --break: #8da2f0;
    --warn-bg: #2b1d12;
    --warn-border: #8a4f22;
    --danger: #f87171;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

[hidden] { display: none !important; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; margin-bottom: 0.75rem; }
h3 { font-size: 0.85rem; margin: 1rem 0 0.4rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); font-size: 0.9rem; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  min-width: 0;
}
textarea { width: 100%; resize: vertical; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0.75rem 0 0.25rem; }
label.check { display: flex; align-items: center; gap: 0.35rem; margin: 0; white-space: nowrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.card-head h2 { margin: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 16px 0.5rem;
  max-width: 1200px;
  margin: 0 auto;
}
.topbar-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.chip {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
}
.chip.on { border-color: var(--work); color: var(--work); }
.chip.off { border-color: var(--off); color: var(--off); }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem 16px 2rem;
}
@media (max-width: 860px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
}

.banner {
  max-width: 1168px;
  margin: 0.5rem 16px;
  padding: 0.9rem 1rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
}
@media (min-width: 1232px) { .banner { margin: 0.5rem auto; } }
.banner p { font-weight: 600; margin-bottom: 0.6rem; }

.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 1rem; }

.now-line { margin-bottom: 0.6rem; }
.tag { font-size: 0.78rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid currentColor; }
.tag.work { color: var(--work); }
.tag.off_task { color: var(--off); }
.tag.unclear { color: var(--unclear); }
.tag.break { color: var(--break); }

.bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface-2);
}
.bar > span { display: block; height: 100%; }
.seg-work { background: var(--work); }
.seg-off { background: var(--off); }
.seg-unclear { background: var(--unclear); }
.seg-break { background: var(--break); }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; align-items: end; }
.day { text-align: center; font-size: 0.75rem; color: var(--muted); }
.day.weekend .day-name { font-weight: 700; color: var(--text); }
.day-col {
  display: flex;
  flex-direction: column-reverse;
  height: 72px;
  background: var(--surface-2);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 4px;
}
.day-col > span { display: block; width: 100%; }
.day-min { font-variant-numeric: tabular-nums; }

.break-row { margin-top: 0.9rem; }

.list { list-style: none; margin: 0 0 0.75rem; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list li.done .grow { text-decoration: line-through; color: var(--muted); }
.list .meta { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.list .overdue { color: var(--danger); }
.icon-btn { padding: 0.1rem 0.5rem; background: transparent; border-color: transparent; color: var(--muted); }

.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.inline-form input[name="title"], .inline-form input[name="message"] { flex: 1 1 160px; }

.day-heading { font-size: 0.8rem; color: var(--muted); margin: 0.6rem 0 0.2rem; font-weight: 600; }
.empty { color: var(--muted); font-size: 0.9rem; padding: 0.3rem 0; }

.briefing h3 { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 1rem; margin: 0 0 0.4rem; }
.briefing p { margin: 0.2rem 0 0.5rem; }
.briefing strong { display: block; margin-top: 0.7rem; }
.briefing ul { margin: 0.2rem 0; padding-left: 1.2rem; }

.chat-log {
  max-height: 340px;
  min-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.msg { padding: 0.5rem 0.75rem; border-radius: 10px; max-width: 92%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); }
.msg.assistant { align-self: flex-start; background: var(--surface-2); }
.msg .actions { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-top: 0.4rem; }
.msg .action { font-size: 0.75rem; border: 1px solid var(--border); border-radius: 999px; padding: 0 0.5rem; background: var(--surface); color: var(--text); }
.msg .action.fail { color: var(--danger); border-color: var(--danger); }
.chat-form { display: flex; gap: 0.5rem; }
.chat-form input { flex: 1; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 0.5rem; }
.login-card input { width: 100%; }

dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 1.2rem;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 1rem; }
.grid4 input { width: 100%; }
@media (max-width: 600px) { .two { grid-template-columns: 1fr; } }
.learned {
  margin: 0;
  padding: 0.6rem 0.75rem;
  background: var(--surface-2);
  border-radius: 8px;
  white-space: pre-wrap;
  font: inherit;
  font-size: 0.85rem;
  max-height: 160px;
  overflow: auto;
}
code { background: var(--surface-2); padding: 0 0.3rem; border-radius: 4px; }
