/* workos-app — neo-brutalist skin, light-only. Paper field, chunky ink
   borders, hard zero-blur offset shadows, press-to-depress, multi-color
   highlighter section tabs, a blocky display face (Black Han Sans) for
   headings + a mono utility layer for data. All class names / DOM shapes
   here are a contract with app.js — restyle only. */

:root {
  color-scheme: light;

  /* ── surfaces ─────────────────────────────────────────────── */
  --paper:    #FBF6E8;  /* app field — bright warm paper          */
  --card:     #FFFFFF;  /* raised surfaces                        */
  --sunk:     #F0E9D6;  /* inset / secondary fills                */
  --ink:      #17130B;  /* borders + primary text + hard shadows  */
  --ink-soft: #6E6650;  /* dimmed / utility text                  */

  /* ── marker colors (fully saturated, framed in ink on paper) ─ */
  --brand:    #FFD23D;  /* yellow  — header, due, memo, send      */
  --pop:      #6C4CFF;  /* violet  — primary action, in-progress  */
  --pop-ink:  #FFFFFF;  /* text on --pop                          */
  --alert:    #FF5A3C;  /* coral   — overdue, danger, errors      */
  --go:       #B4F03A;  /* lime    — done                         */
  --cyan:     #35D6E8;  /* cyan    — this-week tab, form chips     */
  --pink:     #FF4D8D;  /* pink    — today tab, high priority      */
  --on-accent:#17130B;  /* dark ink text on bright markers         */

  --bd: 2.5px;
  --radius: 6px;
  --shadow:    5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);

  --display: "Black Han Sans", "Pretendard", -apple-system, BlinkMacSystemFont, sans-serif;
  --font:    "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono:    ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--sunk);           /* framing rail on wide screens */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: 640px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

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

:focus-visible {
  outline: 3px solid var(--pop);
  outline-offset: 2px;
}

/* ── Header ───────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--brand);
  color: var(--on-accent);
  border-bottom: var(--bd) solid var(--ink);
}
.topbar h1 {
  flex: 1;
  margin: 0;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  display: grid;
  place-items: center;
  min-width: 42px;
  min-height: 42px;
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .05s ease, box-shadow .05s ease;
}
.icon-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

/* ── Tab bar (오늘 / 일정 / 완료) ─────────────────────────────── */
.tabbar {
  display: flex;
  padding: 12px 14px 2px;
  background: var(--paper);
}
.tab {
  flex: 1;
  text-align: center;
  text-decoration: none;
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: .02em;
  color: var(--ink);
  background: var(--card);
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow-sm);
  padding: 9px 0 10px;
}
.tab + .tab { border-left-width: 0; }
.tab:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.tab:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }
.tab.active { background: var(--pop); color: var(--pop-ink); }

/* ── Main / views ─────────────────────────────────────────────── */
#app {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px calc(108px + env(safe-area-inset-bottom));
}

/* ── Today: section tabs + task cards ─────────────────────────── */
.groups h2 {
  display: inline-block;
  margin: 26px 0 14px;
  padding: 4px 13px 6px;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: .02em;
  color: var(--on-accent);
  background: var(--brand);
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow-sm);
}
.groups h2:first-child { margin-top: 4px; }
/* structural color coding — renderTodayGroups always emits these 4 h2 in
   order: 1=지연 2=오늘 3=이번 주 4=진행 중. Scoped to #today-groups so the
   schedule/completed views (also .groups) don't inherit it. */
#today-groups h2:nth-of-type(1) { background: var(--alert); }                      /* 지연   */
#today-groups h2:nth-of-type(2) { background: var(--pink); }                       /* 오늘   */
#today-groups h2:nth-of-type(3) { background: var(--cyan); }                       /* 이번 주 */
#today-groups h2:nth-of-type(4) { background: var(--pop); color: var(--pop-ink); } /* 진행 중 */
/* schedule day headers: today pops, past days recede, future stay brand yellow */
#schedule-groups h2.is-today { background: var(--pop); color: var(--pop-ink); }
#schedule-groups h2.is-past  { background: var(--sunk); color: var(--ink-soft); }

.group-empty {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  padding: 2px 2px 8px;
}

.task-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 15px;
  margin-bottom: 14px;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease;
}
.task-card:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.task-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: .01em;
  line-height: 1.3;
  margin-bottom: 10px;
}
.task-meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }

/* ── 메모 인박스 ─────────────────────────────────────────────── */
.memo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--card);
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 13px;
  margin-bottom: 12px;
}
.memo-text {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
}
.memo-del {
  flex: none;
  width: 30px;
  height: 30px;
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  background: var(--sunk);
  color: var(--ink);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.memo-del:hover { background: var(--alert); color: #fff; }
.memo-del:active { transform: translate(2px, 2px); }
.memo-edit {
  flex: 1;
  min-width: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  padding: 6px 8px;
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  resize: vertical;
}
.memo-edit:focus { outline: none; box-shadow: var(--shadow-sm); }

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 3px 8px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
}
.badge--status { background: var(--sunk); }
.badge--status.is-active { background: var(--pop); color: var(--pop-ink); }
.badge--status.is-done   { background: var(--go);  color: var(--on-accent); }
.badge--priority.is-high { background: var(--pink); color: var(--on-accent); }
.badge--due     { background: var(--brand); color: var(--on-accent); }
.badge--project { background: var(--card); }
.badge--time      { background: var(--cyan); color: var(--on-accent); font-weight: 700; }
.badge--meeting   { background: var(--pink); color: var(--on-accent); }
.badge--done-date { background: var(--go);   color: var(--on-accent); }

/* meeting context line under a schedule card (상대·시간·장소 from 미팅 정보) */
.sched-info {
  margin-top: 9px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-soft);
  border-left: 3px solid var(--ink);
  padding-left: 9px;
}

/* ── Empty-state illustration (schedule/completed) ────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 44px 20px;
}
.empty-state img {
  width: 176px;
  height: 176px;
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty-state p {
  margin: 0;
  font-family: var(--display);
  font-size: 17px;
  color: var(--ink-soft);
}

/* ── Task detail ──────────────────────────────────────────────── */
.detail-title {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: .01em;
  line-height: 1.25;
  margin: 6px 0 20px;
}
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 2px solid var(--ink);
}
.field-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  min-width: 84px;
}
.field-row select,
.field-row input[type=date] {
  flex: 1;
  max-width: 62%;
  background: var(--card);
  color: var(--ink);
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 9px 10px;
  min-height: 42px;
  font-weight: 600;
}
.field-static { flex: 1; text-align: right; font-size: 14px; font-weight: 600; color: var(--ink); }
.chip-list { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.chip {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--sunk);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 3px 9px;
}
.memo-block {
  margin-top: 20px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.55;
  color: var(--on-accent);
  background: var(--brand);      /* sticky-note */
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.detail-link {
  display: inline-block;
  margin-top: 20px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 3px solid var(--pop);
  padding-bottom: 1px;
}

/* ── Forms (new task) ─────────────────────────────────────────── */
.form-field { margin-bottom: 18px; }
.form-field label {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 7px;
}
.form-field input[type=text],
.form-field input[type=date],
.form-field select {
  width: 100%;
  background: var(--card);
  color: var(--ink);
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 11px 12px;
  min-height: 46px;
  font-weight: 600;
}
.picker-row { display: flex; gap: 8px; }
.picker-row input { flex: 1; }
.picker-row button {
  padding: 0 16px;
  font-weight: 700;
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .05s ease, box-shadow .05s ease;
}
.picker-row button:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.chips { margin-top: 8px; display: flex; flex-wrap: wrap; }
.chip-editable {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--cyan);
  color: var(--on-accent);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 4px 6px 4px 10px;
  margin: 7px 7px 0 0;
}
.chip-editable button {
  border: none;
  background: transparent;
  color: var(--on-accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  padding: 0 2px;
}

/* ── Ask (natural-language box) ───────────────────────────────── */
#ask-input {
  width: 100%;
  min-height: 100px;
  background: var(--card);
  color: var(--ink);
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 11px 12px;
  font-family: var(--font);
  font-weight: 600;
  resize: vertical;
}
.answer-card {
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  background: var(--card);
  padding: 14px 16px;
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.55;
  margin-top: 16px;
}
.ask-loading {
  font-family: var(--mono);
  color: var(--ink-soft);
  margin-top: 12px;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.accent-btn {
  font-family: var(--display);
  background: var(--pop);
  color: var(--pop-ink);
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 11px 18px;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: .02em;
  min-height: 48px;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease;
}
.accent-btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.accent-btn:disabled { opacity: .45; transform: none; box-shadow: var(--shadow); cursor: not-allowed; }
.ghost-btn {
  font-family: var(--display);
  background: var(--card);
  color: var(--ink);
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 11px 18px;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: .02em;
  min-height: 48px;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease;
}
.ghost-btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.link-btn {
  background: transparent;
  border: none;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--pop);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.full-width { width: 100%; }
.btn-row { display: flex; gap: 12px; margin-top: 22px; }
.btn-row > * { flex: 1; }

/* ── Memo bar (fixed footer) ──────────────────────────────────── */
.memo-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 640px;
  display: flex;
  gap: 10px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: var(--bd) solid var(--ink);
}
.memo-bar input {
  flex: 1;
  background: var(--card);
  color: var(--ink);
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  padding: 11px 14px;
  min-height: 46px;
  font-weight: 600;
}
/* primary = AI send (묻거나 시키기); the small 📝 stays a neutral .icon-btn */
.memo-bar #cmd-send {
  font-family: var(--display);
  padding: 0 18px;
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  background: var(--brand);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: .02em;
  min-height: 46px;
  cursor: pointer;
  transition: transform .05s ease, box-shadow .05s ease;
}
.memo-bar #cmd-send:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.memo-bar .icon-btn { min-height: 46px; min-width: 46px; font-size: 18px; }

/* ── Overlay / bottom sheet ───────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 17, 9, .55);
}
.sheet {
  width: 100%;
  max-width: 640px;
  max-height: 85dvh;
  overflow-y: auto;
  background: var(--card);
  color: var(--ink);
  border: var(--bd) solid var(--ink);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
}
.sheet h2 {
  display: inline-block;
  margin: 0 0 16px;
  padding: 3px 13px 5px;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: .02em;
  color: var(--on-accent);
  background: var(--brand);
  border: var(--bd) solid var(--ink);
}
.summary-text { font-size: 15px; line-height: 1.55; margin-bottom: 18px; }
.error-text {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--alert);
  margin: 6px 0;
}
.disambig-block { margin: 16px 0; }
.disambig-block .name-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.candidate-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  color: var(--ink);
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 11px 12px;
  margin-bottom: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, box-shadow .05s ease;
}
.candidate-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

/* ── Toast (inverted chunk) ───────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 30;
  width: calc(100% - 28px);
  max-width: 612px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--ink);
  color: var(--paper);
  border: var(--bd) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 15px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}
.toast .link-btn { color: var(--brand); }

/* ── Motion off ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .task-card:active, .accent-btn:active, .ghost-btn:active, .icon-btn:active,
  .candidate-btn:active, .memo-bar button:active, .picker-row button:active {
    transform: none;
  }
}
