/* Juniper for the web. Tokens are Juniper's (ui/theme/Theme.kt, Type.kt); light by default, dark from the system.
   Styling is classes only: the page's CSP forbids inline styles (spec sections 1.6 and 4.1). */

:root {
  color-scheme: light dark;
  --primary: #2B59C3;
  --on-primary: #FFFFFF;
  --primary-container: #E6EDFB;
  --surface: #FFFFFF;
  --surface-variant: #F6F7F9;
  --surface-container: #F3F4F7;
  --on-surface: #15171C;
  --on-surface-variant: #4A505C;
  --outline: #C9CDD4;
  --outline-variant: #DDE0E5;
  --error: #B4410E;
  --divider: #ECEEF1;
  --text-muted: #5B616E;
  --overdue: #B4410E;
  --complete: #1F7A4D;
  --chip-fill: #F0F1F4;
  --nav-indicator: #D6E0F8;
  --badge: #C62828;
  --priority-highest: #C62828;
  --priority-high: #E0670B;
  --priority-normal: #3A7280;
  --priority-low: #2B59C3;
  --priority-lowest: #8A909C;
  --priority-tint-highest: #FDECEA;
  --priority-tint-high: #FDF0E6;
  --priority-tint-normal: #E7F1F3;
  --priority-tint-low: #E9EFFB;
  --priority-tint-lowest: transparent;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #B0C6FF;
    --on-primary: #002C71;
    --primary-container: #243B73;
    --surface: #121418;
    --surface-variant: #1C1F24;
    --surface-container: #1A1C21;
    --on-surface: #E3E4E8;
    --on-surface-variant: #B9BEC8;
    --outline: #5A606B;
    --outline-variant: #3A3F47;
    --error: #FF9A6B;
    --divider: #2A2E35;
    --text-muted: #A3A9B4;
    --overdue: #FF9A6B;
    --complete: #2E8F5E;
    --chip-fill: #262A31;
    --nav-indicator: #2B3F6E;
    --badge: #E5484D;
    --priority-highest: #FF7A72;
    --priority-high: #FF9F5A;
    --priority-normal: #7FB4C2;
    --priority-low: #8FAEFF;
    --priority-lowest: #A3A9B4;
    --priority-tint-highest: rgba(255, 122, 114, 0.18);
    --priority-tint-high: rgba(255, 159, 90, 0.18);
    --priority-tint-normal: rgba(127, 180, 194, 0.18);
    --priority-tint-low: rgba(143, 174, 255, 0.18);
    --priority-tint-lowest: transparent;
  }
}

* { box-sizing: border-box; }

html, body, #root { height: 100%; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--font);
  font-size: 15px;
  line-height: 21px;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--primary); }
button { font: inherit; color: inherit; }

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

/* Type scale */
.screen-title { font-size: 22px; line-height: 28px; font-weight: 600; }
.panel-title { font-size: 19px; line-height: 26px; font-weight: 600; }
.row-title { font-size: 16px; line-height: 22px; font-weight: 500; }
.section-header { font-size: 13px; line-height: 18px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.secondary { font-size: 14px; line-height: 20px; color: var(--on-surface-variant); }
.meta { font-size: 13px; line-height: 18px; color: var(--text-muted); }
.overdue { color: var(--overdue); font-weight: 600; }

/* Icons */
.icon { width: 24px; height: 24px; fill: currentColor; flex: none; }

/* Layout: sidebar, list, details (spec section 4.2) */
.app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  position: relative;
}
.app.has-panel { grid-template-columns: 260px minmax(0, 1fr) 380px; }

.banner {
  grid-column: 1 / -1;
  padding: 8px 16px;
  background: var(--primary-container);
  color: var(--on-surface);
  font-size: 14px;
  text-align: center;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 8px;
  background: var(--surface-variant);
  border-right: 1px solid var(--divider);
}
.brand { padding: 8px 12px 12px; font-size: 19px; line-height: 26px; font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { padding: 16px 12px 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 20px;
  color: var(--on-surface);
  text-decoration: none;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
}
.nav-item:hover { background: var(--surface-container); }
.nav-item.selected { background: var(--nav-indicator); }
.nav-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .icon { width: 20px; height: 20px; }
.count { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--chip-fill); border: 1px solid var(--outline); flex: none; margin: 0 5px; }
.sidebar-footer { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 2px; }
.status-line { padding: 4px 12px; font-size: 13px; line-height: 18px; color: var(--text-muted); }
.status-line.attention { color: var(--overdue); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.main-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--divider);
}
.main-header .grow { flex: 1; min-width: 0; }
.main-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 24px; }
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-container); }
.icon-button.menu-button { display: none; }

.empty { padding: 32px 0; color: var(--text-muted); }
.card { padding: 16px; border: 1px solid var(--outline-variant); border-radius: 12px; background: var(--surface-variant); }
.placeholder-list { color: var(--text-muted); }

/* Details panel */
.panel { display: none; min-height: 0; overflow-y: auto; padding: 16px 24px; border-left: 1px solid var(--divider); background: var(--surface); }
.app.has-panel .panel { display: block; }
.back-button {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 14px;
  line-height: 40px;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 20px;
  border: 1px solid var(--outline);
  border-radius: 20px;
  background: transparent;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* Snackbar */
.snackbar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--on-surface);
  color: var(--surface);
  font-size: 14px;
}

/* Narrower than 1100 px: the details panel covers the list, with a back button */
@media (max-width: 1099px) {
  .app.has-panel { grid-template-columns: 260px minmax(0, 1fr); }
  .app.has-panel .main { display: none; }
  .app.has-panel .panel { grid-column: 2; }
  .back-button { display: inline-flex; }
}

/* Narrower than 700 px: the sidebar becomes a menu */
@media (max-width: 699px) {
  .app, .app.has-panel { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .app.menu-open .sidebar { display: flex; grid-column: 1; }
  .app.menu-open .main, .app.menu-open .panel { display: none; }
  .app.has-panel .panel { grid-column: 1; }
  .icon-button.menu-button { display: inline-flex; }
  .main-header, .main-body, .panel { padding-left: 16px; padding-right: 16px; }
}

.sidebar, .main, .panel { grid-row: 2; }

/* Lists, rows and row actions (spec sections 4.3 to 4.6) */
.add-task { margin-bottom: 16px; }
.add-task-input {
  width: 100%; min-height: 44px; padding: 0 16px; border: 1px solid var(--outline); border-radius: 22px;
  background: var(--surface); color: var(--on-surface); font: inherit;
}
.field-error { padding: 4px 16px 0; font-size: 13px; color: var(--error); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { padding: 4px 12px; border: 1px solid var(--outline-variant); border-radius: 16px; font-size: 13px; color: var(--on-surface-variant); }
.section { margin-bottom: 8px; }
.section-header { padding: 12px 0 4px; }
.section-header.overdue { color: var(--overdue); }
.row {
  position: relative; display: flex; align-items: flex-start; gap: 8px; min-height: 56px; padding: 6px 4px;
  border-radius: 8px; cursor: pointer;
}
.row:hover { background: var(--surface-variant); }
.row.open { background: var(--primary-container); }
.row-main { flex: 1; min-width: 0; padding-top: 7px; }
.row-title.muted { color: var(--text-muted); }
.row-title.struck { text-decoration: line-through; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-top: 2px; font-size: 13px; line-height: 18px; color: var(--text-muted); }
.meta-item { display: inline-flex; align-items: center; gap: 4px; }
.meta-item .icon { width: 16px; height: 16px; }
.meta-item.today-text { color: var(--primary); font-weight: 600; }
.meta-item.overdue-text { color: var(--overdue); font-weight: 600; }
.tag { padding: 0 8px; border-radius: 10px; background: var(--chip-fill); color: var(--text-muted); font-size: 12px; }
.row-project { padding-top: 10px; white-space: nowrap; }
.check {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0;
  border: 0; background: transparent; cursor: pointer; position: relative; color: var(--surface);
}
.check::before {
  content: ""; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--priority-normal); background: var(--priority-tint-normal);
}
.check.dashed::before { border-style: dashed; }
.check.checked::before { background: var(--priority-normal); }
.check .icon { position: absolute; width: 16px; height: 16px; }
.check.p-highest::before { border-color: var(--priority-highest); background: var(--priority-tint-highest); }
.check.p-high::before { border-color: var(--priority-high); background: var(--priority-tint-high); }
.check.p-low::before { border-color: var(--priority-low); background: var(--priority-tint-low); }
.check.p-lowest::before { border-color: var(--priority-lowest); background: var(--priority-tint-lowest); }
.check.p-highest.checked::before { background: var(--priority-highest); }
.check.p-high.checked::before { background: var(--priority-high); }
.check.p-low.checked::before { background: var(--priority-low); }
.check.p-lowest.checked::before { background: var(--priority-lowest); }
.menu-anchor { position: relative; flex: none; }
.row-menu-button { opacity: 0.6; }
.row:hover .row-menu-button, .row:focus-within .row-menu-button { opacity: 1; }
.menu-backdrop { position: fixed; inset: 0; z-index: 10; }
.menu {
  position: absolute; right: 0; top: 40px; z-index: 11; display: flex; flex-direction: column; min-width: 180px; padding: 4px 0;
  border: 1px solid var(--outline-variant); border-radius: 8px; background: var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.menu-item { padding: 0 16px; min-height: 40px; border: 0; background: transparent; text-align: left; cursor: pointer; font-size: 14px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-container); }
.completed-toggle {
  margin: 16px 0; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text-muted);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.completed-toggle:hover { background: var(--surface-variant); }
.dialog { max-width: 420px; padding: 24px; border: 1px solid var(--outline-variant); border-radius: 16px; background: var(--surface); color: var(--on-surface); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.date-input { margin-top: 12px; min-height: 40px; font: inherit; }
.snackbar-region { position: fixed; left: 0; right: 0; bottom: 24px; display: flex; justify-content: center; pointer-events: none; z-index: 20; }
.snackbar-region .snackbar { position: static; transform: none; pointer-events: auto; }
.snackbar-action { border: 0; background: transparent; color: var(--primary-container); font-weight: 600; cursor: pointer; text-transform: uppercase; }
.menu-close { display: none; }
@media (max-width: 699px) { .app.menu-open .menu-close { display: inline-flex; } .brand { display: flex; align-items: center; } }

/* Details panel, comments and search (spec sections 4.8 to 4.10) */
.panel:focus { outline: none; }
.field { margin-top: 16px; }
.field-label { margin-bottom: 4px; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--text-muted); }
.field-input {
  display: block; width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--outline); border-radius: 8px;
  background: var(--surface); color: var(--on-surface); font: inherit; resize: vertical;
}
.field-input[aria-invalid="true"] { border-color: var(--error); }
.field-input:disabled { color: var(--text-muted); background: var(--surface-variant); }
.field-input.title-input { font-size: 19px; line-height: 26px; font-weight: 600; }
.field .field-error { padding: 4px 0 0; }
.status-text { margin-top: 4px; }
.date-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.date-row { display: flex; align-items: center; gap: 4px; }
.date-row .field-input { flex: 1; min-width: 0; }
.priority-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.priority-button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border: 1px solid var(--outline);
  border-radius: 18px; background: transparent; font-size: 14px; cursor: pointer;
}
.priority-button.selected { border-width: 2px; font-weight: 600; background: var(--surface-container); }
.priority-button .swatch { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--priority-normal); background: var(--priority-tint-normal); }
.priority-button.p-highest .swatch { border-color: var(--priority-highest); background: var(--priority-tint-highest); }
.priority-button.p-high .swatch { border-color: var(--priority-high); background: var(--priority-tint-high); }
.priority-button.p-low .swatch { border-color: var(--priority-low); background: var(--priority-tint-low); }
.priority-button.p-lowest .swatch { border-color: var(--priority-lowest); background: var(--priority-tint-lowest); }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.tag-list:empty { display: none; }
.tag-chip { display: inline-flex; align-items: center; gap: 2px; padding: 0 4px 0 12px; min-height: 28px; border-radius: 14px; background: var(--chip-fill); font-size: 13px; }
.tag-list .tag-chip:not(:has(.chip-remove)) { padding-right: 12px; }
.chip-remove { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 12px; background: transparent; cursor: pointer; }
.chip-remove .icon { width: 16px; height: 16px; }
.chip-remove:hover { background: var(--surface-container); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.button.danger { color: var(--error); }
.comments-header { margin-top: 24px; padding-bottom: 4px; }
.comment { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--divider); }
.comment-body { flex: 1; min-width: 0; }
.comment-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-add { margin-top: 8px; }
.date-fields .field { min-width: 0; }
.date-fields .field-input { padding-left: 8px; padding-right: 8px; }

/* Sign-in, waiting and connect screens (spec section 5); Settings outside the shell (25d) */
.identity { max-width: 480px; margin: 0 auto; padding: 12vh 16px 32px; }
.identity .screen-title { margin-bottom: 12px; }
.identity p + p, .identity .secondary + .actions { margin-top: 12px; }
.identity .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.identity .notice { margin-bottom: 16px; color: var(--on-surface); }
.identity .hint { margin-top: 16px; }
.settings { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; }
.settings .setting { padding: 12px 0; border-bottom: 1px solid var(--divider); }
.settings .setting-label { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--text-muted); }
.settings a.setting { display: block; text-decoration: none; color: inherit; }
.settings .actions { margin-top: 24px; }
.settings .version { margin-top: 24px; }
.bar { padding: 8px 16px; background: var(--primary-container); color: var(--on-surface); font-size: 14px; text-align: center; }
.bar .button { margin-left: 8px; min-height: 32px; line-height: 32px; }

/* Approving and recovering (25e) */
.identity .steps { margin: 12px 0 16px 20px; padding: 0; }
.identity .steps li { margin: 4px 0; }
.identity .code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 32px; font-weight: 600; letter-spacing: 2px; margin: 16px 0; }
.identity.recovery { max-width: 720px; padding-top: 6vh; }
.word-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(8, auto); grid-auto-flow: column; gap: 8px 12px; margin-top: 16px; }
.word-cell { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.word-number { width: 1.6em; text-align: right; color: var(--on-surface-variant, inherit); font-size: 13px; }
.word-input { flex: 1; min-width: 0; padding: 6px 8px; font: inherit; border: 1px solid var(--outline-variant); border-radius: 6px; background: var(--surface); color: var(--on-surface); }
.suggestions { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px; padding-left: calc(1.6em + 6px); }
.chip { font: inherit; font-size: 13px; padding: 2px 8px; border: 1px solid var(--outline-variant); border-radius: 12px; background: var(--surface-variant); color: var(--on-surface); cursor: pointer; }
.identity .error { margin-top: 12px; color: var(--error); }
@media (max-width: 600px) { .word-grid { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(12, auto); } }
.settings .setting .attention { color: var(--overdue); }
.sync-log { margin: 16px 0 0; padding: 12px; border: 1px solid var(--outline-variant); border-radius: 8px; background: var(--surface-variant); font: 12px/16px ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.problems { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: 12px; }
.problems .card .headline { font-size: 16px; font-weight: 500; }
.problems .card .copy-text { margin: 6px 0; }
.problems .card .actions { margin-top: 12px; display: flex; gap: 8px; }
.snackbar-action { margin-left: 12px; }
