:root {
  --bg: #fdfcf5;
  --surface: #ffffff;
  --ink: #0a0a0a;
  --line: #0a0a0a;
  --dim: #55555a;

  /* bright palette */
  --yellow: #ffde00;
  --cyan: #12d3ff;
  --pink: #ff5c8a;
  --purple: #7c4dff;
  --lime: #b6ff2e;
  --orange: #ff8a00;
  --green: #17d67a;
  --red: #ff3b3b;

  --radius: 12px;
  --bd: 3px solid var(--line);
  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --font: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --maxw: 640px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  overflow-x: hidden;
  font-weight: 600;
}

body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

.app { max-width: var(--maxw); margin: 0 auto; padding: 16px; }
.hidden { display: none !important; }

/* ---- Header ---- */
.header { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 16px; }
.header h1 { font-size: 30px; margin: 0; font-weight: 900; letter-spacing: -0.02em; text-transform: uppercase; }
.header .date { color: var(--dim); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }

/* ---- KPI cards ---- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.kpi {
  border: var(--bd); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 14px 6px; text-align: center;
}
.kpi:nth-child(1) { background: var(--yellow); }
.kpi:nth-child(2) { background: var(--cyan); }
.kpi:nth-child(3) { background: var(--pink); }
.kpi .num { font-size: 30px; font-weight: 900; line-height: 1; color: var(--ink); }
.kpi .label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px; }

/* ---- Section titles ---- */
.section-title {
  font-size: 15px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.02em;
  margin: 26px 2px 12px; display: flex; justify-content: space-between; align-items: center;
}

/* ---- Cards / list items ---- */
.card {
  background: var(--surface); border: var(--bd); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 14px 16px; margin-bottom: 12px;
}

.todo { display: flex; align-items: flex-start; gap: 12px; }
.todo .check {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; border: var(--bd);
  background: var(--surface); cursor: pointer; display: grid; place-items: center; margin-top: 1px;
}
.todo .check.done { background: var(--green); }
.todo .check.done::after { content: "✓"; color: var(--ink); font-size: 18px; font-weight: 900; }
.todo .body { flex: 1; min-width: 0; cursor: pointer; }
.todo .title { font-weight: 800; font-size: 16px; word-wrap: break-word; }
.todo.done .title { color: var(--dim); text-decoration: line-through; }
.todo .meta { font-size: 12px; color: var(--dim); margin-top: 3px; font-weight: 700; }
.todo-actions { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 0 0 auto; }
.iconbtn { background: none; border: none; color: var(--ink); font-size: 18px; font-weight: 900; cursor: pointer; padding: 0 4px; line-height: 1; }
.iconbtn:active { color: var(--purple); }
.del { color: var(--ink); background: none; border: none; font-size: 22px; font-weight: 900; line-height: 1; cursor: pointer; padding: 0 4px; flex: 0 0 auto; }
.del:active { color: var(--red); }

/* ---- Goal tree ---- */
.goal-annual { margin-bottom: 18px; }
.goal-annual > .card { background: var(--yellow); }
.goal-node .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.goal-node .row .t { flex: 1; font-weight: 800; font-size: 16px; cursor: pointer; }
.gn-head { display: flex; align-items: center; gap: 8px; }
.gn-head .t { flex: 1; font-weight: 800; font-size: 16px; cursor: pointer; }
.gn-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.gn-actions .del { margin-left: auto; }
.goal-monthly { margin: 8px 0 8px 14px; }
.goal-weekly { margin: 6px 0 6px 14px; }
.goal-monthly .card { background: var(--cyan); padding: 11px 13px; margin-bottom: 8px; }
.goal-weekly .card { background: var(--lime); padding: 10px 12px; margin-bottom: 7px; }
.chip {
  font-size: 11px; font-weight: 800; color: var(--ink); background: var(--surface);
  border: 2px solid var(--ink); border-radius: 999px; padding: 2px 9px; text-transform: uppercase; white-space: nowrap;
}
.muted { color: var(--dim); font-weight: 700; }
.desc { font-size: 13px; color: var(--ink); margin-top: 6px; font-weight: 600; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--purple); color: #fff; border: var(--bd); border-radius: var(--radius);
  padding: 13px 18px; font-size: 15px; font-weight: 900; font-family: var(--font);
  text-transform: uppercase; letter-spacing: 0.01em; cursor: pointer; width: 100%;
  box-shadow: var(--shadow-sm); transition: transform 0.05s, box-shadow 0.05s;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn.secondary { background: var(--surface); color: var(--ink); }
.btn.small { width: auto; padding: 7px 12px; font-size: 12px; border-width: 2px; box-shadow: 3px 3px 0 var(--ink); border-radius: 9px; }
.btn.ghost { background: var(--yellow); color: var(--ink); width: auto; padding: 7px 12px; font-size: 12px; border-width: 2px; box-shadow: 2px 2px 0 var(--ink); border-radius: 9px; }
.btn.pink { background: var(--pink); color: var(--ink); }
.btn.cyan { background: var(--cyan); color: var(--ink); }

/* ---- Forms / inputs ---- */
input, textarea, select {
  width: 100%; background: var(--surface); color: var(--ink);
  border: var(--bd); border-radius: 10px; padding: 12px 14px;
  font-size: 16px; font-family: var(--font); font-weight: 700; margin-bottom: 12px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; box-shadow: var(--shadow-sm); }
label { font-size: 13px; font-weight: 800; text-transform: uppercase; display: block; margin-bottom: 5px; letter-spacing: 0.02em; }

/* ---- Bottom nav ---- */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface);
  border-top: var(--bd); display: flex; justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); z-index: 50;
}
.nav button {
  background: none; border: none; color: var(--ink); font-family: var(--font);
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.02em;
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; flex: 1; opacity: 0.5;
}
.nav button .ico { font-size: 22px; }
.nav button.active { opacity: 1; }
.nav button.active .ico { transform: scale(1.15); }

/* ---- Lock screen ---- */
.lock { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.lock .logo { font-size: 56px; margin-bottom: 8px; }
.lock h2 { margin: 0 0 4px; font-size: 30px; font-weight: 900; text-transform: uppercase; }
.lock p { color: var(--dim); margin: 0 0 24px; font-weight: 700; }
.lock .form { width: 100%; max-width: 320px; }
.lock input { text-align: center; font-size: 26px; font-weight: 900; letter-spacing: 0.3em; box-shadow: var(--shadow-sm); }
.error { color: var(--red); font-size: 14px; font-weight: 800; min-height: 20px; margin-bottom: 8px; }

/* ---- Modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 10, 10, 0.45); display: flex; align-items: flex-end; justify-content: center; z-index: 100; }
.modal {
  background: var(--surface); border: var(--bd); border-bottom: none;
  border-radius: 20px 20px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  width: 100%; max-width: var(--maxw); max-height: 88vh; overflow-y: auto; box-shadow: 0 -6px 0 var(--ink);
}
.modal h3 { margin: 0 0 16px; font-size: 22px; font-weight: 900; text-transform: uppercase; }
.modal .actions { display: flex; gap: 10px; margin-top: 6px; }

/* ---- Empty states ---- */
.empty { text-align: center; color: var(--dim); padding: 36px 16px; font-weight: 700; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: calc(96px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--ink); border: var(--bd); border-color: var(--ink); color: #fff;
  padding: 11px 18px; border-radius: 10px; font-size: 14px; font-weight: 800; z-index: 200;
  opacity: 0; transition: opacity 0.2s; pointer-events: none; box-shadow: var(--shadow-sm); max-width: 90vw;
}
.toast.show { opacity: 1; }

.spinner { width: 26px; height: 26px; border: 4px solid var(--ink); border-top-color: var(--pink); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; padding: 48px; }

/* ---- AI breakdown review tree ---- */
.bd-tree { margin-top: 8px; }
.bd-month { margin-bottom: 14px; }
.bd-week { margin: 4px 0 4px 18px; }
.bd-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; font-weight: 700; cursor: pointer; }
.bd-row input { width: auto; margin: 0; flex: 0 0 auto; width: 20px; height: 20px; accent-color: var(--purple); border-radius: 5px; }
.bd-todo { margin-left: 18px; color: var(--dim); }

/* ---- Week divider ---- */
.week-divider {
  display: flex; justify-content: space-between; align-items: center;
  margin: 22px 2px 14px; padding-top: 14px; border-top: 3px dashed var(--ink);
}
.week-divider span:first-child { font-size: 15px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.03em; background: var(--purple); color: #fff; padding: 4px 10px; border-radius: 999px; }

/* ---- Week / Done day groups ---- */
.day-group { margin-bottom: 18px; }
.day-head { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 8px; gap: 8px; }
.day-name { font-size: 15px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.02em; display: flex; align-items: center; gap: 8px; }
.day-empty { color: var(--dim); font-weight: 700; font-size: 13px; padding: 2px 4px 6px; }
.day-group.is-today .day-name { color: var(--purple); }
.day-group.is-today > .day-head { border-bottom: 3px solid var(--purple); padding-bottom: 6px; }
.add-day { font-size: 24px; font-weight: 900; }

/* ---- Diary ---- */
.diary-entry .txt { cursor: pointer; }
.rec-panel { text-align: center; }
.lang-toggle { display: inline-flex; gap: 0; border: var(--bd); border-radius: 10px; overflow: hidden; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.lang-toggle button {
  background: var(--surface); border: none; border-right: 3px solid var(--ink); color: var(--ink);
  font-family: var(--font); font-weight: 800; font-size: 13px; padding: 8px 12px; cursor: pointer; text-transform: uppercase;
}
.lang-toggle button:last-child { border-right: none; }
.lang-toggle button.active { background: var(--purple); color: #fff; }
.rec-btn {
  width: 96px; height: 96px; border-radius: 50%; border: var(--bd); background: var(--pink);
  color: var(--ink); font-size: 40px; cursor: pointer; box-shadow: var(--shadow); margin: 8px auto 12px;
  display: grid; place-items: center; transition: transform 0.05s, box-shadow 0.05s;
}
.rec-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.rec-btn.recording { background: var(--red); color: #fff; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: var(--shadow); } 50% { box-shadow: 5px 5px 0 var(--ink), 0 0 0 8px rgba(255,59,59,0.25); } }
.rec-status { font-weight: 800; text-transform: uppercase; font-size: 14px; margin-bottom: 6px; }
.rec-timer { font-size: 32px; font-weight: 900; font-variant-numeric: tabular-nums; }
.diary-day { margin-bottom: 20px; }
.diary-day .day-label { font-size: 14px; font-weight: 900; text-transform: uppercase; margin: 0 2px 8px; letter-spacing: 0.02em; }
.diary-entry { background: var(--lime); border: var(--bd); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 12px 14px; margin-bottom: 10px; position: relative; }
.diary-entry .txt { font-weight: 600; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.diary-entry .stamp { font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--dim); margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
