:root {
  --canvas: #ffffff;
  --card: #f6f6f8;
  --hairline: #ececef;
  --ink: #141416;
  --ink-fg: #ffffff;
  --text: #141416;
  --muted: #6e6e73;
  --subtle: #a1a1a6;
  --done: #74b816;
  --warn: #d97706;
  --danger: #ee4444;
  --dot-empty: #e4e4e7;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scrollbar-gutter: stable; }
html, body { height: 100%; background: var(--canvas); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
svg { display: block; flex-shrink: 0; }
input:focus, textarea:focus { outline: none; }

/* Auth Screen */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 20px;
}
.auth-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 28px; }
.auth-brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.brand-mark {
  width: 60px; height: 60px; border-radius: 16px; overflow: hidden;
  border: 1px solid var(--hairline); background: var(--canvas);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
}
.brand-mark img { width: 100%; height: 100%; display: block; object-fit: cover; }
.auth-brand h1 { font-size: 26px; font-weight: 700; letter-spacing: -.4px; }
.auth-brand p { font-size: 14px; color: var(--muted); }
.field-line {
  display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--hairline);
  padding: 12px 0; transition: border-color .18s;
}
.field-line:focus-within { border-bottom-color: var(--ink); }
.field-line input { flex: 1; border: none; background: transparent; font-size: 15px; }
.btn-primary {
  width: 100%; height: 48px; border-radius: 999px; background: var(--ink); color: var(--ink-fg);
  font-size: 15px; font-weight: 600; transition: opacity .18s, transform .12s;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .42; cursor: not-allowed; }
.btn-secondary {
  height: 40px; padding: 0 18px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--hairline); font-size: 14px; font-weight: 500; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn-secondary:hover { background: #efeff2; }
.btn-secondary:disabled { opacity: .45; cursor: not-allowed; }
.btn-danger-soft {
  height: 40px; padding: 0 18px; border-radius: 999px; background: rgba(238, 68, 68, .1);
  color: var(--danger); font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn-danger-soft:disabled { opacity: .55; cursor: not-allowed; }
.text-btn:disabled { opacity: .5; cursor: not-allowed; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.8px solid currentColor; border-right-color: transparent;
  display: inline-block; flex-shrink: 0;
  animation: uiSpin 650ms linear infinite;
}
.spinner.sm { width: 12px; height: 12px; border-width: 1.6px; }
.sync-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; line-height: 1.3; color: var(--subtle);
}
@keyframes uiSpin {
  to { transform: rotate(360deg); }
}
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); }
.auth-switch button { font-weight: 600; color: var(--ink); margin-left: 4px; }
.error-inline { color: var(--danger); font-size: 13px; line-height: 1.5; }
.success-inline { color: var(--done); font-size: 13px; line-height: 1.5; }

/* App Shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--hairline); padding: 20px 14px; display: flex; flex-direction: column;
  gap: 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.sidebar-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
.sidebar-brand .brand-en { font-size: 12px; font-weight: 500; color: var(--subtle); letter-spacing: .2px; }
.sidebar-brand .mini-mark {
  width: 28px; height: 28px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--hairline); background: var(--canvas);
  display: block; flex-shrink: 0;
}
.sidebar-brand .mini-mark img { width: 100%; height: 100%; display: block; object-fit: cover; }
.ai-trigger {
  width: 100%; height: 42px; border-radius: 999px; background: var(--ink); color: var(--ink-fg);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 600; transition: opacity .15s;
}
.ai-trigger:hover { opacity: .9; }
.ai-trigger kbd {
  font-family: var(--mono); font-size: 11px; opacity: .65; padding: 1px 6px;
  border-radius: 6px; background: rgba(255, 255, 255, .14);
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 4px; font-size: 12px; font-weight: 600; color: var(--subtle);
}
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: var(--radius-sm); font-size: 14px; color: var(--muted); transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--card); color: var(--ink); font-weight: 600; }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--subtle); font-variant-numeric: tabular-nums; }
.nav-item.active .count { color: var(--ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--hairline); display: flex; align-items: center; justify-content: space-between; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 6px; border-radius: var(--radius-sm); flex: 1; text-align: left; }
.user-chip:hover { background: var(--card); color: var(--text); }
.avatar-dot {
  width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: var(--ink-fg);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0;
}

/* Main Workspace */
.main { max-width: 780px; width: 100%; margin: 0 auto; padding: 28px 32px 96px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 44px; margin-bottom: 18px; }
.page-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -.5px; line-height: 44px; white-space: nowrap; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  color: var(--muted); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--card); color: var(--ink); }
.sort-select {
  height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--hairline);
  background: var(--canvas); font-size: 13px; color: var(--muted); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.sort-select:hover { border-color: #d4d4d8; color: var(--ink); }
select.sort-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding: 0 28px 0 12px; line-height: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
}

/* Calendar Strip & Month Grid (Unified Single-Source Geometry) */
.cal-head { display: flex; align-items: center; justify-content: space-between; height: 32px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.cal-title { font-size: 13px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 32px; }
.cal-controls { display: flex; align-items: center; gap: 4px; height: 32px; }
.text-btn {
  height: 28px; display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; line-height: 1.35; color: var(--muted); padding: 0 6px; border-radius: 6px;
}
.text-btn:hover { color: var(--ink); background: var(--card); }
.text-btn.strong { color: var(--ink); font-weight: 600; }
.cal-arrow { width: 28px; justify-content: center; padding: 0; font-size: 15px; }
.cal-toggle-btn { min-width: 58px; justify-content: center; }
.cal-box { padding-bottom: 14px; border-bottom: 1px solid var(--hairline); margin-bottom: 14px; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); column-gap: 4px; margin-bottom: 4px; }
.wd-label { height: 20px; line-height: 20px; text-align: center; font-size: 11px; color: var(--subtle); }
.wd-label.active { color: var(--ink); font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; grid-auto-rows: 50px; }
.day-cell {
  height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 0; border-radius: 10px;
}
.day-cell:hover { background: var(--card); }
.day-num {
  width: 32px; height: 32px; line-height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-size: 14px; font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.day-cell.today .day-num { border: 1.5px solid rgba(20, 20, 22, .35); font-weight: 600; }
.day-cell.selected .day-num { background: var(--ink); color: var(--ink-fg); border-color: transparent; font-weight: 600; }
.day-cell.out .day-num { color: var(--subtle); }
.day-dots { display: flex; gap: 3px; height: 5px; align-items: center; justify-content: center; flex-shrink: 0; }
.day-dots span { width: 4px; height: 4px; border-radius: 50%; }

/* Quick Capture Bar */
.quick-bar {
  display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--hairline);
  padding: 10px 0; margin-bottom: 24px; transition: border-color .18s;
}
.quick-bar:focus-within { border-bottom-color: var(--ink); }
.quick-plus { width: 28px; height: 28px; display: grid; place-items: center; color: var(--subtle); flex-shrink: 0; }
.quick-bar:focus-within .quick-plus { color: var(--ink); }
.quick-bar input { flex: 1; min-width: 0; border: none; background: transparent; font-size: 15px; }
.quick-bar input::placeholder { color: var(--subtle); }
.quick-scope-btn {
  height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.3; color: var(--muted);
  background: var(--card); border: 1px solid var(--hairline);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.quick-scope-btn:hover { color: var(--ink); border-color: #d4d4d8; }
.quick-scope-btn.week { background: var(--ink); color: var(--ink-fg); border-color: var(--ink); font-weight: 600; }
.quick-submit {
  width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--ink-fg);
  display: grid; place-items: center; flex-shrink: 0;
}

/* Sections & Hairline Task Rows */
.section { margin-bottom: 24px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; min-height: 28px; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.section-head .left { display: flex; align-items: center; gap: 6px; }
.section-head.overdue .left { color: var(--danger); }
.section-head .num { color: var(--subtle); font-variant-numeric: tabular-nums; font-weight: 500; }
.task-list { display: flex; flex-direction: column; }
.task-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 0;
  border-bottom: 1px solid var(--hairline); transition: background .12s;
}
.task-row:last-child { border-bottom: none; }
.task-check {
  width: 28px; height: 28px; display: grid; place-items: center; flex-shrink: 0; color: var(--subtle);
}
.task-check.done { color: var(--ink); }
.task-body { flex: 1; min-width: 0; text-align: left; display: flex; align-items: center; gap: 12px; }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.task-title { font-size: 15px; line-height: 1.4; color: var(--text); word-break: break-word; }
.task-title-text {
  display: inline;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 54%;
  background-size: 0% 1.5px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-size 260ms cubic-bezier(0.22, 1, 0.36, 1), color 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.task-row.done .task-title-text { color: var(--muted); background-size: 100% 1.5px; }
.task-row.is-completing, .task-row.is-uncompleting { pointer-events: none; }
.task-row.is-completing .task-title-text { color: var(--muted); background-size: 100% 1.5px; }
.task-row.done.is-uncompleting .task-title-text { color: var(--text); background-size: 0% 1.5px; }
.task-row.is-fading { opacity: 0; transition: opacity 160ms cubic-bezier(0.4, 0, 1, 1); }
.task-row.expired-day-only { opacity: .62; }
.task-row.expired-day-only .task-title { color: var(--muted); }
.day-only-pill {
  display: inline-flex; align-items: center;
  font-size: 11px; line-height: 1.2; padding: 2px 6px; border-radius: 999px;
  background: var(--card); color: var(--muted); border: 1px solid var(--hairline);
}
.day-only-pill.expired { color: var(--subtle); }
.task-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; line-height: 1.3; color: var(--muted); margin-top: 2px; }
.priority-bars { display: inline-flex; align-items: flex-end; gap: 1.5px; height: 10px; }
.priority-bars span { width: 2.2px; border-radius: 1px; background: var(--dot-empty); }
.priority-bars.p1 span:nth-child(1) { background: var(--muted); }
.priority-bars.p2 span:nth-child(1), .priority-bars.p2 span:nth-child(2) { background: var(--warn); }
.priority-bars.p3 span { background: var(--danger); }
.task-trailing { display: flex; align-items: center; gap: 10px; flex-shrink: 0; font-size: 12px; font-variant-numeric: tabular-nums; }
.step-count { color: var(--subtle); }
.step-count.all-done { color: var(--done); }
.due-text { color: var(--muted); font-weight: 500; }
.due-text.overdue { color: var(--danger); }
.due-text.today { color: var(--ink); }
.task-row.done .due-text { color: var(--subtle); font-weight: 400; }
.row-del { opacity: 0; color: var(--subtle); padding: 4px; transition: opacity .15s, color .15s; }
.task-row:hover .row-del { opacity: 1; }
.row-del:hover { color: var(--danger); }

/* Subject Cards (Lists Overview) */
.metrics-strip {
  display: grid; grid-template-columns: repeat(2, 1fr); border-bottom: 1px solid var(--hairline);
  padding-bottom: 16px; margin-bottom: 24px;
}
.metric-col { text-align: center; padding: 6px; border-radius: var(--radius-sm); }
.metric-col:hover { background: var(--card); }
.metric-col + .metric-col { border-left: 1px solid var(--hairline); }
.metric-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric-lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.subject-card {
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--radius-lg);
  padding: 18px; text-align: left; display: flex; flex-direction: column; gap: 16px;
  transition: transform .15s, border-color .15s;
}
.subject-card:hover { border-color: #d4d4d8; transform: translateY(-1px); }
.slot-row { display: flex; align-items: center; gap: 12px; }
.sub-badge { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.dot-strip { flex: 1; display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.dot-strip span { width: 9px; height: 9px; border-radius: 50%; }
.dot-strip .s-done { background: var(--done); }
.dot-strip .s-overdue { background: var(--danger); }
.dot-strip .s-todo { border: 1.6px solid rgba(20, 20, 22, .45); }
.dot-strip .s-empty { width: 6px; height: 6px; background: var(--dot-empty); }
.sub-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.sub-name { font-size: 16px; font-weight: 600; }
.sub-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.micro-bar-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.micro-ratio { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.micro-bar { width: 84px; height: 4.5px; border-radius: 99px; background: var(--dot-empty); overflow: hidden; }
.micro-bar > i { display: block; height: 100%; border-radius: 99px; background: var(--done); transition: width .25s; }
.micro-bar.overdue > i { background: var(--danger); }

/* Empty State */
.empty-state { text-align: center; padding: 56px 16px; color: var(--muted); }
.empty-dots { display: inline-flex; gap: 12px; margin-bottom: 14px; }
.empty-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--dot-empty); }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-state p { font-size: 13px; color: var(--muted); }

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 20, 22, .28); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
  transition: opacity 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-backdrop.is-closing { opacity: 0; pointer-events: none; }
.modal {
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  background: var(--canvas); border-radius: var(--radius-lg); border: 1px solid var(--hairline);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .14); padding: 22px 24px; display: flex; flex-direction: column; gap: 18px;
  transition: opacity 220ms cubic-bezier(0.22, 1, 0.36, 1), transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-backdrop.is-closing .modal { opacity: 0; transform: translateY(8px) scale(0.985); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 17px; font-weight: 700; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 6px; }
.detail-title { width: 100%; border: none; font-size: 20px; font-weight: 600; resize: none; }
.prop-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--hairline); font-size: 14px;
}
.prop-row label { color: var(--muted); }
.inline-opts { display: flex; align-items: center; gap: 14px; }
.opt-btn { font-size: 14px; color: var(--muted); padding: 4px 2px; border-bottom: 2px solid transparent; }
.opt-btn.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.opt-btn.active.p2 { color: var(--warn); border-bottom-color: var(--warn); }
.opt-btn.active.p3 { color: var(--danger); border-bottom-color: var(--danger); }
.subtask-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--hairline); font-size: 14px;
}
.subtask-row.done span { color: var(--muted); text-decoration: line-through; }
.notes-area {
  width: 100%; min-height: 84px; border: none; resize: vertical; font-size: 14px; line-height: 1.6;
}

/* AI Planner Modal */
.ai-textarea {
  width: 100%; min-height: 96px; padding: 14px; border-radius: var(--radius-md);
  background: var(--card); border: 1px solid var(--hairline); resize: vertical;
  font-size: 15px; line-height: 1.5; transition: border-color .15s;
}
.ai-textarea:focus { border-color: var(--ink); background: var(--canvas); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.example-chip {
  font-size: 12px; color: var(--muted); padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--hairline); background: var(--canvas);
}
.example-chip:hover { border-color: var(--ink); color: var(--ink); }
.preview-box { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; border-top: 1px solid var(--hairline); }
.preview-summary { font-size: 14px; font-weight: 600; color: var(--ink); }
.op-row {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--hairline); cursor: pointer;
}
.op-row:last-child { border-bottom: none; }
.op-row input[type="checkbox"] { margin-top: 2px; accent-color: var(--ink); width: 16px; height: 16px; flex-shrink: 0; }
.op-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; line-height: 1.3; padding: 2px 7px; border-radius: 6px; flex-shrink: 0; margin-top: 1px;
  background: var(--card); color: var(--ink);
}
.op-badge.create_task, .op-badge.create_subject { background: rgba(116, 184, 22, .14); color: #4d7c0f; }
.op-badge.delete_task, .op-badge.delete_subject, .op-badge.clear_completed { background: rgba(238, 68, 68, .12); color: var(--danger); }
.op-badge.update_task, .op-badge.update_subject, .op-badge.postpone_overdue { background: rgba(217, 119, 6, .12); color: var(--warn); }
.op-info { flex: 1; min-width: 0; }
.op-title { font-size: 14px; font-weight: 500; line-height: 1.45; }
.op-detail { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.op-color-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.op-steps { margin-top: 4px; padding-left: 14px; font-size: 12px; color: var(--muted); }
.op-steps li.done { text-decoration: line-through; color: var(--subtle); }

/* Color & Icon Swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; position: relative; }
.swatch.active::after { content: ""; position: absolute; inset: 3px; border: 2px solid #fff; border-radius: 50%; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200;
  background: var(--ink); color: var(--ink-fg); border-radius: 999px;
  padding: 10px 16px; display: flex; align-items: center; gap: 12px;
  font-size: 13px; box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  animation: toastIn 260ms cubic-bezier(0.22, 1, 0.36, 1);
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.is-leaving { opacity: 0; transform: translate(-50%, 6px); pointer-events: none; }
.toast button { color: #a3e635; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.toast button:disabled { opacity: .65; cursor: not-allowed; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Mobile */
.mobile-bar { display: none; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px 16px 104px; }
  .mobile-bar {
    position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 50;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; pointer-events: none;
  }
  .mobile-pill {
    pointer-events: auto; display: flex; gap: 4px; padding: 5px; border-radius: 999px;
    background: rgba(255, 255, 255, .92); backdrop-filter: blur(18px);
    border: 1px solid var(--hairline); box-shadow: 0 8px 28px rgba(0, 0, 0, .08);
  }
  .mobile-pill button {
    padding: 8px 18px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted);
  }
  .mobile-pill button.active { background: var(--card); color: var(--ink); }
  .mobile-ai-orb {
    pointer-events: auto; width: 52px; height: 52px; border-radius: 50%;
    background: var(--ink); color: var(--ink-fg); display: grid; place-items: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  }
}

/* Toggle Switch (dayOnly) */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--dot-empty);
  position: relative; transition: background .16s;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18);
  transition: transform .16s;
}
.switch input:checked + .switch-track { background: var(--ink); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }

/* Attachments & Tool Trace (AI Planner + Feedback) */
.attach-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px 0 6px;
  border-radius: 10px; background: var(--card); border: 1px solid var(--hairline);
  font-size: 12px; line-height: 1.35; color: var(--text); max-width: 220px;
}
.attach-chip img { width: 20px; height: 20px; border-radius: 5px; object-fit: cover; flex-shrink: 0; }
.attach-chip .attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip button { color: var(--subtle); padding: 2px; display: inline-flex; align-items: center; justify-content: center; }
.attach-chip button:hover { color: var(--danger); }
.attach-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 30px; font-size: 12px; line-height: 1.4; color: var(--subtle);
}
.attach-bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.attach-trigger {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px;
  border-radius: 999px; background: var(--card); border: 1px solid var(--hairline);
  font-size: 12px; font-weight: 600; line-height: 1.4; color: var(--ink);
  cursor: pointer; flex-shrink: 0; transition: background .15s, border-color .15s;
}
.attach-trigger:hover { background: #efeff2; border-color: #dcdce0; }
.attach-hint { font-size: 12px; line-height: 1.4; color: var(--subtle); }
.tool-trace { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.trace-chip {
  display: inline-flex; align-items: center;
  font-size: 11px; line-height: 1.3; color: var(--muted); background: var(--card); border: 1px solid var(--hairline);
  padding: 2px 8px; border-radius: 999px;
}

/* AI Live Animated Progress Card */
.ai-progress-card {
  background: var(--card); border: 1px solid var(--hairline); border-radius: var(--radius-md);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.ai-progress-track {
  height: 3px; border-radius: 999px; background: var(--dot-empty); overflow: hidden; position: relative;
}
.ai-progress-track > i {
  position: absolute; top: 0; bottom: 0; left: 0; width: 42%; border-radius: 999px;
  background: var(--ink); will-change: transform;
  animation: aiSweep 1.35s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
.ai-progress-active {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; line-height: 1.4; font-weight: 500; color: var(--ink);
}
.ai-pulse-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ink); flex-shrink: 0;
  animation: aiDotPulse 1.2s ease-in-out infinite;
}
.ai-phase-dots {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
}
.ai-phase-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--dot-empty);
  transition: background .25s ease, transform .25s ease;
}
.ai-phase-dots span.done { background: var(--done); }
.ai-phase-dots span.active {
  background: var(--ink);
  animation: aiDotPulse 1.35s ease-in-out infinite;
}
.ai-progress-steps {
  display: flex; flex-direction: column; gap: 5px; padding-top: 4px;
  border-top: 1px solid var(--hairline);
}
.ai-progress-step {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; line-height: 1.4; color: var(--muted);
}
.ai-progress-step svg { color: var(--done); }

/* AI Multi-turn Refinement & Apply Confirmation */
.ai-prompt-recap {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--card);
  border: 1px solid var(--hairline); font-size: 13px; line-height: 1.4; color: var(--muted);
}
.ai-prompt-recap-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.ai-refine-bar {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px;
  border-radius: 999px; background: var(--card); border: 1px solid var(--hairline);
  transition: border-color .15s, background .15s;
}
.ai-refine-bar:focus-within { border-color: var(--ink); background: var(--canvas); }
.ai-refine-bar input {
  flex: 1; min-width: 0; border: none; background: transparent;
  font-size: 13px; line-height: 1.4; color: var(--text);
}
.ai-refine-bar input::placeholder { color: var(--subtle); }
.ai-refine-send {
  height: 30px; padding: 0 14px; border-radius: 999px; background: var(--ink); color: var(--ink-fg);
  font-size: 12px; font-weight: 600; line-height: 1.3; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.ai-refine-send:disabled { opacity: .28; cursor: not-allowed; }
.ai-refine-history {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 11px; line-height: 1.35; color: var(--subtle);
}
.ai-apply-btn {
  width: auto; padding: 0 24px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background-color 220ms ease, opacity 180ms ease;
}
.ai-apply-btn.is-applied { background: var(--done); color: #fff; opacity: 1; cursor: default; }
.ai-apply-btn .ai-btn-dot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  animation: aiDotPulse 1.1s ease-in-out infinite;
}
.preview-box.is-settling { opacity: .68; pointer-events: none; transition: opacity 180ms ease; }
.toast-msg { display: inline-flex; align-items: center; gap: 7px; line-height: 1.35; }
.toast-msg svg { color: #a3e635; }
@keyframes aiSweep {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(260%); }
}
@keyframes aiDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.8); }
}
@media (prefers-reduced-motion: reduce) {
  .ai-progress-track > i, .ai-pulse-dot, .ai-phase-dots span.active, .ai-apply-btn .ai-btn-dot, .toast { animation: none; }
  .ai-progress-track > i { width: 100%; opacity: .35; }
}

/* Segmented Tabs, Feedback & Changelog */
.seg-tabs {
  display: inline-flex; padding: 3px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--hairline); gap: 2px;
}
.seg-tabs button {
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--muted);
}
.seg-tabs button.active { background: var(--canvas); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.settings-links {
  display: flex; flex-direction: column; border-top: 1px solid var(--hairline); padding-top: 8px; gap: 2px;
}
.settings-link-row {
  display: flex; align-items: center; justify-content: space-between; padding: 9px 6px;
  border-radius: 8px; font-size: 14px; color: var(--text); text-decoration: none;
}
.settings-link-row:hover { background: var(--card); }
.settings-link-row .sub-val { font-size: 12px; color: var(--subtle); }

.fb-card {
  border: 1px solid var(--hairline); border-radius: var(--radius-md); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px; background: var(--canvas);
}
.fb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.fb-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; line-height: 1.25;
  padding: 2px 8px; border-radius: 999px; background: var(--card); color: var(--muted);
}
.badge.bug { background: rgba(238, 68, 68, .1); color: var(--danger); }
.badge.feature { background: rgba(47, 128, 237, .12); color: #2563eb; }
.badge.st-open { background: rgba(217, 119, 6, .12); color: var(--warn); }
.badge.st-in_progress { background: rgba(47, 128, 237, .12); color: #2563eb; }
.badge.st-resolved { background: rgba(116, 184, 22, .14); color: #4d7c0f; }
.badge.st-wontfix { background: var(--card); color: var(--subtle); }
.fb-title { font-size: 15px; font-weight: 600; }
.fb-body { font-size: 13px; color: var(--text); line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.fb-meta { font-size: 11px; color: var(--subtle); }
.fb-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-thumb {
  width: 72px; height: 72px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--hairline); cursor: zoom-in;
}
.fb-reply {
  background: var(--card); border-radius: 10px; padding: 10px 12px;
  font-size: 13px; line-height: 1.5; color: var(--text);
}
.fb-reply-label { font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }

.release-item { padding: 14px 0; border-bottom: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 6px; }
.release-item:last-child { border-bottom: none; }
.release-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.release-ver { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--ink); }
.release-title { font-size: 15px; font-weight: 600; }
.release-notes { font-size: 13px; color: var(--muted); line-height: 1.65; white-space: pre-wrap; }

/* Settings Modal (Clean Sidebar Tabs) */
.modal.modal-settings {
  max-width: 720px; padding: 0; overflow: hidden; gap: 0;
  height: min(600px, 86vh); max-height: 86vh;
}
.settings-layout { display: grid; grid-template-columns: 176px 1fr; height: 100%; min-height: 0; }
.settings-nav {
  border-right: 1px solid var(--hairline); padding: 18px 10px;
  display: flex; flex-direction: column; gap: 4px; background: #fbfbfc;
}
.settings-nav-title { font-size: 13px; font-weight: 700; color: var(--ink); padding: 4px 10px 10px; }
.settings-nav-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 9px 10px; border-radius: var(--radius-sm); font-size: 13px; color: var(--muted);
  text-align: left; transition: background .15s, color .15s;
}
.settings-nav-item:hover { background: var(--card); color: var(--text); }
.settings-nav-item.active { background: var(--card); color: var(--ink); font-weight: 600; }
.settings-nav-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--hairline); }
.settings-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.settings-pane-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--hairline); flex-shrink: 0;
}
.settings-pane-head h2 { font-size: 16px; font-weight: 700; }
.settings-pane-body {
  flex: 1; overflow-y: auto; padding: 18px 22px 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.settings-card {
  border: 1px solid var(--hairline); border-radius: var(--radius-md); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 12px; background: var(--canvas);
}
@media (max-width: 660px) {
  .modal.modal-settings { height: min(640px, 90vh); }
  .settings-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .settings-nav {
    border-right: none; border-bottom: 1px solid var(--hairline);
    flex-direction: row; overflow-x: auto; padding: 10px 12px; gap: 6px; scrollbar-width: none;
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav-title, .settings-nav-foot { display: none; }
  .settings-nav-item { width: auto; white-space: nowrap; padding: 7px 12px; }
}

/* Admin Console Layout */
.admin-shell { max-width: 960px; margin: 0 auto; padding: 28px 24px 80px; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--hairline); margin-bottom: 22px; }
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.stat-card { border: 1px solid var(--hairline); border-radius: var(--radius-md); padding: 14px 16px; }
.stat-val { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.admin-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-reply-form { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; border-top: 1px solid var(--hairline); }
.admin-reply-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.78); z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
@media (max-width: 680px) {
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
}
