/* ─── Reset & base ─────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --font-mono: 'DM Mono', 'Courier New', monospace;
  --font-serif: 'Fraunces', Georgia, serif;

  --bg:          #f7f4ef;
  --bg-card:     #ffffff;
  --bg-chat:     #f0ece4;
  --text-primary:#1a1714;
  --text-muted:  #7a7570;
  --text-hint:   #b0aa9f;
  --border:      rgba(26,23,20,.12);
  --border-mid:  rgba(26,23,20,.22);

  --duck-yellow: #f5c842;
  --duck-dark:   #3a2600;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-pill: 999px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #1a1714;
    --bg-card:     #242018;
    --bg-chat:     #1e1b16;
    --text-primary:#f0ece4;
    --text-muted:  #8a847a;
    --text-hint:   #5a5550;
    --border:      rgba(240,236,228,.10);
    --border-mid:  rgba(240,236,228,.20);
  }
}

html { font-size: 16px; }

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem 4rem;
}

/* ─── App shell ─────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 420px;
}

/* ─── Mode switcher ─────────────────────────────────────── */
.mode-bar {
  display: flex;
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 2rem;
  background: var(--bg-card);
}

.mode-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .06em;
  padding: 8px 22px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .2s, color .2s;
  white-space: nowrap;
}

.mode-btn.active {
  background: var(--text-primary);
  color: var(--bg);
}

/* ─── Pomodoro section ──────────────────────────────────── */
#pomodoroMode {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

#duckMode {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

section[hidden] {
  display: none !important;
}

.canvas-zone {
  width: 240px;
  height: 240px;
  margin-bottom: 1.5rem;
}

#timerCanvas {
  width: 240px;
  height: 240px;
  display: block;
}

.timer-display {
  font-family: var(--font-serif);
  font-size: 56px;
  font-weight: 300;
  color: var(--text-primary);
  letter-spacing: -.03em;
  margin-bottom: .4rem;
  font-variant-numeric: tabular-nums;
}

.phase-label {
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

/* ─── Buttons ───────────────────────────────────────────── */
.controls {
  display: flex;
  gap: 10px;
  margin-bottom: 1.5rem;
}

.btn {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .08em;
  padding: 9px 24px;
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: background .15s, transform .1s;
}

.btn:hover   { background: var(--border); }
.btn:active  { transform: scale(.96); }

.btn-primary {
  background: var(--text-primary);
  color: var(--bg);
  border-color: var(--text-primary);
}

.btn-primary:hover { opacity: .82; background: var(--text-primary); }

/* ─── Color picker ──────────────────────────────────────── */
.color-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: .6rem;
}

.color-label {
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-right: 2px;
}

.color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c);
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
  outline: none;
}

.color-dot:hover   { transform: scale(1.18); }
.color-dot:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; }
.color-dot.selected { border-color: var(--text-primary); }

/* ─── Session pips ──────────────────────────────────────── */
.sessions-row {
  display: flex;
  gap: 8px;
  margin-top: 1.2rem;
}

.session-pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border-mid);
  transition: background .35s;
}

.session-pip.done { background: #e34a30; }

/* ─── Duck section ──────────────────────────────────────── */
.duck-zone {
  width: 240px;
  height: 240px;
  margin-bottom: 1.25rem;
  cursor: pointer;
  outline: none;
}

.duck-zone:focus-visible canvas {
  outline: 2px solid var(--text-primary);
  border-radius: 50%;
}

#duckCanvas {
  width: 240px;
  height: 240px;
  display: block;
}

/* ─── Chat ──────────────────────────────────────────────── */
.chat-box {
  width: 100%;
  background: var(--bg-chat);
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border);
  overflow: hidden;
  margin-bottom: 1rem;
}

.chat-messages {
  min-height: 130px;
  max-height: 180px;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 4px; }

.msg {
  font-size: 13px;
  line-height: 1.55;
  max-width: 82%;
  padding: 8px 13px;
  border-radius: 15px;
  word-break: break-word;
  animation: msgIn .18s ease-out;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-user {
  align-self: flex-end;
  background: var(--text-primary);
  color: var(--bg);
  border-bottom-right-radius: 4px;
}

.msg-duck {
  align-self: flex-start;
  background: var(--duck-yellow);
  color: var(--duck-dark);
  border-bottom-left-radius: 4px;
}

.chat-input-row {
  display: flex;
  border-top: 0.5px solid var(--border);
}

.chat-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 11px 14px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  outline: none;
}

.chat-input::placeholder { color: var(--text-hint); }

.send-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 11px 16px;
  border: none;
  border-left: 0.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s;
  white-space: nowrap;
}

.send-btn:hover { color: var(--text-primary); }

.duck-hint {
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--text-hint);
  text-align: center;
}

/* ─── Toast notification ────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--text-primary);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .06em;
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  z-index: 100;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}
