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

:root {
  --bg:           #f7f7f6;
  --surface:      #ffffff;
  --sidebar-bg:   #f0efed;
  --border:       #e4e3e0;
  --border-light: #eeede9;
  --text:         #1a1917;
  --text-muted:   #888580;
  --text-faint:   #b8b4ae;
  --accent:       #1a1917;
  --accent-soft:  #eeecea;
  --user-bg:      #1a1917;
  --user-text:    #ffffff;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.05);
  --shadow-md:    0 4px 20px rgba(0,0,0,.12);
  --radius:       12px;
  --radius-sm:    8px;
  --radius-xs:    6px;
  --font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono:         "SF Mono", "Fira Code", Menlo, monospace;
  --header-h:     52px;
  --sidebar-w:    248px;
  --transition:   0.17s ease;

  /* Priority */
  --high:   #ef4444;
  --medium: #f59e0b;
  --low:    #22c55e;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ─── App shell ─────────────────────────────────────────────────── */
/* position:fixed + inset:0 pins all four edges to the visual viewport.
   On iOS Safari the visual viewport bottom tracks the keyboard top, so the
   shell shrinks smoothly with the keyboard animation — no JS needed. */
#app {
  display: flex; flex-direction: column;
  position: fixed; inset: 0;
  overflow: hidden;
}

/* ─── Header ────────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 200;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.btn-menu {
  width: 32px; height: 32px;
  border-radius: var(--radius-xs);
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); flex-shrink: 0;
}
.btn-menu:hover { background: var(--accent-soft); color: var(--text); }

.app-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  user-select: none;
}

.btn-settings { color: var(--text-muted); }
.btn-settings:hover { color: var(--text); background: var(--accent-soft); }

.sidebar-bottom {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}
.sidebar-username {
  font-size: 12px; color: var(--text-muted); max-width: 110px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Nav icons */
.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-btn:hover { background: var(--accent-soft); color: var(--text); }
.nav-btn.active { background: var(--text); color: var(--surface); }
.nav-btn .badge {
  min-width: 16px; height: 16px;
  background: #ef4444; color: white;
  border-radius: 8px; font-size: 10px; font-weight: 700;
  padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}
.nav-btn.active .badge { background: rgba(255,255,255,.25); }

.nav-home-icon-wrap {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
}
.filter-active-dot {
  position: absolute; top: -3px; right: -4px;
  width: 7px; height: 7px; border-radius: 50%;
  background: #f59e0b;
  border: 1.5px solid var(--surface);
}
.nav-btn.active .filter-active-dot { border-color: var(--text); }

/* ─── Body ──────────────────────────────────────────────────────── */
.app-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ─── Views ─────────────────────────────────────────────────────── */
.view {
  display: none;
  width: 100%; height: 100%;
}
.view.active { display: flex; }

/* ── Chat view ─────────────────────────────────────────────────── */
#view-chat { flex-direction: row; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition);
}
.sidebar.collapsed { width: 0; border-right: none; }

.sidebar-top { padding: 14px 12px 8px; flex-shrink: 0; }

.btn-new-chat {
  display: flex; align-items: center; gap: 7px;
  width: 100%; padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: all var(--transition);
}
.btn-new-chat:hover { background: var(--text); color: white; border-color: var(--text); }

.sidebar-body {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 0 12px;
}
.sidebar-body::-webkit-scrollbar { width: 3px; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Sidebar search */
.sidebar-search-wrap {
  padding: 6px 10px 2px;
  flex-shrink: 0;
}
.sidebar-search {
  width: 100%; height: 30px;
  padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface); color: var(--text);
  font-size: 12px; font-family: var(--font);
  outline: none; transition: border-color var(--transition);
}
.sidebar-search::placeholder { color: var(--text-faint); }
.sidebar-search:focus { border-color: #aaa; }
/* Hide the browser's default clear (×) button for consistency */
.sidebar-search::-webkit-search-cancel-button { -webkit-appearance: none; }

.sidebar-label {
  padding: 10px 14px 4px;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-faint); white-space: nowrap;
}

.thread-item {
  display: flex; align-items: center;
  padding: 0 6px; cursor: pointer;
}
.thread-inner {
  display: flex; align-items: center; flex: 1;
  padding: 7px 8px; border-radius: var(--radius-xs);
  gap: 8px; min-width: 0;
  transition: background var(--transition);
}
.thread-item:hover .thread-inner,
.thread-item.active .thread-inner { background: var(--border); }

.thread-title {
  flex: 1; font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.4;
}
.thread-time { font-size: 11px; color: var(--text-faint); flex-shrink: 0; }

.thread-del {
  width: 22px; height: 22px; border-radius: 5px;
  border: none; background: transparent; color: var(--text-faint);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: all var(--transition); flex-shrink: 0; padding: 0;
}
.thread-item:hover .thread-del { opacity: 1; }
.thread-del:hover { background: #fee2e2; color: #dc2626; }

.sidebar-empty { padding: 8px 14px; font-size: 12px; color: var(--text-faint); font-style: italic; }

/* Main chat */
.chat-main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0; background: var(--surface);
}

.messages {
  flex: 1; overflow-y: auto;
  padding: 28px 0 8px; scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.msg-row {
  padding: 4px 28px;
  max-width: 760px; margin: 0 auto; width: 100%;
  animation: fadeIn .18s ease;
}
.msg-row.user { display: flex; justify-content: flex-end; }

.bubble {
  max-width: 70%;
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 14px; line-height: 1.65;
}
.msg-row.user .bubble {
  background: var(--user-bg); color: var(--user-text);
  border-bottom-right-radius: 4px;
  max-width: 100%; /* constrained by .msg-user-wrap instead */
}
.msg-row.assistant .bubble {
  max-width: 100%; padding: 6px 0;
  background: transparent; color: var(--text);
}

/* Markdown */
.bubble p { margin-bottom: 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 6px 0 6px 18px; }
.bubble li { margin-bottom: 3px; }
.bubble strong { font-weight: 600; }
.bubble code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bg); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 4px;
}
.msg-row.user .bubble code { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.2); }
.bubble pre {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 8px 0;
}
.bubble pre code { background: none; border: none; padding: 0; }

/* Tool hint */
.tool-row {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 28px; max-width: 760px; margin: 0 auto; width: 100%;
  color: var(--text-faint); font-size: 12px;
  animation: fadeIn .15s ease;
}
.tool-dots span {
  display: inline-block; width: 4px; height: 4px;
  border-radius: 50%; background: var(--text-faint);
  margin-right: 2px; animation: dotPulse 1.2s infinite ease-in-out;
}
.tool-dots span:nth-child(2) { animation-delay: .2s; }
.tool-dots span:nth-child(3) { animation-delay: .4s; }

/* Typing */
.typing-row {
  padding: 4px 28px; max-width: 760px; margin: 0 auto; width: 100%;
  animation: fadeIn .15s ease;
}
.typing-dots { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-faint); animation: typingBounce 1.3s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }

/* Empty state */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; gap: 10px; padding: 40px 24px; text-align: center;
}
.empty-title { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.empty-sub { font-size: 14px; color: var(--text-muted); max-width: 300px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: 6px; }
.chip {
  padding: 7px 13px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 13px; cursor: pointer; font-family: var(--font);
  transition: all var(--transition);
}
.chip:hover { background: var(--text); color: var(--surface); border-color: var(--text); }

/* Input */
.input-area {
  flex-shrink: 0;
  padding: 10px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--border-light);
}
.input-wrap {
  max-width: 716px; margin: 0 auto;
  display: flex; align-items: center; gap: 7px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 0 8px 0 14px; height: 46px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-wrap:focus-within {
  border-color: #aaa;
  box-shadow: 0 0 0 3px rgba(0,0,0,.05);
}
#message-input {
  flex: 1; border: none; background: transparent;
  font-family: var(--font); font-size: 14px; color: var(--text);
  outline: none; line-height: 1.4; height: 100%; min-width: 0;
}
#message-input::placeholder { color: var(--text-faint); }

.input-btns { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 7px;
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.icon-btn.recording { background: #fee2e2; color: #dc2626; animation: micPulse 1.5s infinite; }

.send-btn {
  width: 32px; height: 32px; border-radius: 7px;
  border: none; background: var(--user-bg); color: white;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); flex-shrink: 0;
}
.send-btn:hover:not(:disabled) { background: #333; }
.send-btn:disabled { background: var(--border); color: var(--text-faint); cursor: not-allowed; }

.voice-preview {
  font-size: 12px; color: #dc2626; text-align: center;
  padding: 4px 0 0; min-height: 16px; font-style: italic;
  opacity: 0; transition: opacity .2s;
}
.voice-preview.on { opacity: 1; }

/* ── Actions view ───────────────────────────────────────────────── */
#view-actions {
  flex-direction: row;
  overflow: hidden;
}

/* Actions sidebar — narrower nav-only sidebar */
.actions-sidebar {
  width: 180px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition);
}
.actions-sidebar.collapsed { width: 0; border-right: none; overflow: hidden; }

/* Nav buttons inside actions sidebar */
.anav { padding: 4px 8px; display: flex; flex-direction: column; gap: 2px; }
.anav-btn {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 12px;
  border: none; background: transparent; color: var(--text-muted);
  font-size: 13px; font-weight: 500; font-family: var(--font);
  cursor: pointer; border-radius: var(--radius-xs); text-align: left;
  transition: all var(--transition);
}
.anav-btn:hover { background: var(--border); color: var(--text); }
.anav-btn.active { background: var(--text); color: white; }

/* Actions main area */
.actions-main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0; background: var(--bg);
}

/* Tab panels */
.atab { display: none; flex: 1; overflow: hidden; }
.atab.active { display: flex; flex-direction: column; }

.actions-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 28px 20px;
  overflow: hidden;
}

.actions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-shrink: 0;
}

.actions-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.btn-add {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--text); color: white;
  font-size: 13px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: all var(--transition);
}
.btn-add:hover { background: #333; }

/* Actions search */
.actions-search-wrap {
  margin-bottom: 12px;
  flex-shrink: 0;
}
.actions-search {
  width: 100%; height: 36px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: var(--font);
  outline: none; transition: border-color var(--transition);
}
.actions-search::placeholder { color: var(--text-faint); }
.actions-search:focus { border-color: #aaa; box-shadow: 0 0 0 3px rgba(0,0,0,.05); }
.actions-search::-webkit-search-cancel-button { -webkit-appearance: none; }

/* Filter tabs */
.filter-tabs {
  display: flex; gap: 2px;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.ftab {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px; font-family: var(--font);
  cursor: pointer; transition: all var(--transition);
}
.ftab:hover { color: var(--text); }
.ftab.active { background: var(--text); color: white; }

/* Item list */
.items-list {
  flex: 1;
  overflow-y: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.items-list::-webkit-scrollbar { width: 5px; }
.items-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
  animation: fadeIn .15s ease;
}
.item-row:last-child { border-bottom: none; }
.item-row:hover { background: var(--bg); }
.item-row.editing { background: var(--bg); padding: 10px 14px; }
.item-row.completed { opacity: 0.5; }

/* Checkbox */
.item-cb {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  background: transparent;
}
.item-cb:hover { border-color: var(--text); }
.item-row.completed .item-cb { background: var(--text); border-color: var(--text); }
.item-cb svg { display: none; }
.item-row.completed .item-cb svg { display: block; }

/* Item content */
.item-content { flex: 1; min-width: 0; }

.item-name {
  font-size: 14px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.4;
}
.item-row.completed .item-name { text-decoration: line-through; color: var(--text-muted); }

.item-details {
  display: flex; align-items: center; gap: 8px; margin-top: 3px; flex-wrap: wrap;
}
.item-desc {
  font-size: 12px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 300px;
}

/* Priority badge */
.pri-badge {
  font-size: 10.5px; font-weight: 600;
  padding: 1px 7px; border-radius: 10px;
  letter-spacing: 0.02em; flex-shrink: 0;
}
.pri-badge.high   { background: #fee2e2; color: #dc2626; }
.pri-badge.medium { background: #fef3c7; color: #d97706; }
.pri-badge.low    { background: #dcfce7; color: #16a34a; }

.item-due { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.item-id-badge { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); }

/* Item actions */
.item-actions { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; opacity: 0; transition: opacity var(--transition); align-self: flex-start; padding-top: 2px; }
.item-row:hover .item-actions { opacity: 1; }

.item-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); padding: 0;
}
.item-btn:hover { background: var(--accent-soft); color: var(--text); }
.item-btn.danger:hover { background: #fee2e2; color: #dc2626; }

/* Empty actions state */
.actions-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 200px; gap: 8px;
  color: var(--text-faint); font-size: 13px; text-align: center;
}

/* ── Inline edit form ────────────────────────────────────────────── */
.edit-form {
  flex: 1; display: flex; flex-direction: column; gap: 8px;
}
.edit-row { display: flex; gap: 8px; }
.edit-field {
  display: flex; flex-direction: column; gap: 3px; flex: 1;
}
.edit-label { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.edit-input, .edit-select {
  height: 34px; padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: var(--font);
  outline: none; transition: border-color var(--transition);
}
.edit-input:focus, .edit-select:focus { border-color: #aaa; }
.edit-input.full { width: 100%; }
.edit-desc {
  height: 52px; padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: var(--font);
  outline: none; resize: none;
  transition: border-color var(--transition);
}
.edit-desc:focus { border-color: #aaa; }
.edit-btns { display: flex; gap: 6px; justify-content: flex-end; margin-top: 2px; }

.btn-cancel, .btn-save {
  padding: 6px 14px; border-radius: var(--radius-xs);
  font-size: 13px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: all var(--transition);
}
.btn-cancel { border: 1px solid var(--border); background: transparent; color: var(--text-muted); }
.btn-cancel:hover { border-color: var(--text); color: var(--text); }
.btn-save { border: none; background: var(--text); color: white; }
.btn-save:hover { background: #333; }

/* ─── Calendar ──────────────────────────────────────────────────── */
.calendar-wrap {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg);
}

.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px 14px;
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

.cal-title-nav { display: flex; align-items: center; gap: 6px; }

#cal-title {
  font-size: 16px; font-weight: 700; letter-spacing: -0.02em;
  min-width: 200px; color: var(--text);
}

.cal-nav-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.cal-nav-btn:hover { background: var(--text); color: white; border-color: var(--text); }

.cal-today-btn {
  height: 28px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text-muted);
  font-size: 12px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: all var(--transition);
}
.cal-today-btn:hover { background: var(--text); color: white; border-color: var(--text); }

.cal-view-tabs { display: flex; gap: 2px; }

/* Scrollable body */
.cal-body {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; min-height: 0;
}
.cal-body::-webkit-scrollbar { width: 5px; }
.cal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Month view ─────────────────────────────────────────────── */
.cal-month {
  display: flex; flex-direction: column; flex: 1;
  padding: 0 20px 20px;
}

.cal-dow-row {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; margin-bottom: 4px; flex-shrink: 0;
}
.cal-dow {
  text-align: center; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); padding: 4px 0;
}

.cal-month-body { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.cal-week-row {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; flex: 1; min-height: 90px;
}

.cal-day-cell {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-xs); padding: 6px 7px;
  cursor: pointer; overflow: hidden;
  transition: background var(--transition);
  display: flex; flex-direction: column; gap: 2px;
  min-height: 90px;
}
.cal-day-cell:hover { background: var(--accent-soft); }
.cal-day-cell.today  { border-color: var(--accent); border-width: 2px; }
.cal-day-cell.other-month { background: transparent; opacity: 0.5; }

.cal-day-num {
  font-size: 12px; font-weight: 600; color: var(--text); line-height: 1;
}
.today-circle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--text); color: white; font-size: 11px;
}

.cal-item-chip {
  font-size: 10.5px; line-height: 1.3;
  padding: 1px 5px; border-radius: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: default;
}
.cal-item-chip.high   { background: #fee2e2; color: #dc2626; }
.cal-item-chip.medium { background: #fef3c7; color: #d97706; }
.cal-item-chip.low    { background: #dcfce7; color: #16a34a; }
.cal-item-chip.done   { opacity: 0.4; text-decoration: line-through; }

.cal-more { font-size: 10px; color: var(--text-faint); padding-left: 1px; }

/* ── Week view ──────────────────────────────────────────────── */
.cal-week {
  display: flex; flex: 1; gap: 2px;
  padding: 0 20px 20px; min-height: 0; min-width: 0;
  overflow-x: auto;
}
.cal-week-col {
  flex: 1; min-width: 80px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-xs); overflow: hidden;
}
.cal-week-col.today { border-color: var(--accent); border-width: 2px; }

.cal-week-col-header {
  padding: 10px 8px 8px; border-bottom: 1px solid var(--border-light);
  text-align: center; cursor: pointer; flex-shrink: 0;
  transition: background var(--transition);
}
.cal-week-col-header:hover { background: var(--accent-soft); }

.cal-week-dow {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-faint);
}
.cal-week-date {
  font-size: 18px; font-weight: 700; color: var(--text);
  line-height: 1.2; margin-top: 3px;
}
.cal-week-date.today-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--text); color: white; font-size: 16px;
  margin: 3px auto 0;
}

.cal-week-items {
  flex: 1; overflow-y: auto; padding: 6px;
  display: flex; flex-direction: column; gap: 3px;
}
.cal-week-items::-webkit-scrollbar { width: 3px; }
.cal-week-items::-webkit-scrollbar-thumb { background: var(--border); }
.cal-week-items .cal-item-chip { white-space: normal; line-height: 1.4; font-size: 11px; }

/* ── Day view ───────────────────────────────────────────────── */
.cal-day {
  display: flex; flex-direction: column; gap: 2px;
  padding: 0 20px 20px; max-width: 700px; width: 100%;
  margin: 0 auto;
}
.cal-day-empty {
  display: flex; align-items: center; justify-content: center;
  height: 200px; color: var(--text-faint); font-size: 13px; font-style: italic;
}
.cal-day .item-row {
  border: 1px solid var(--border-light); border-radius: var(--radius-xs);
  background: var(--surface);
}

/* ─── Backdrop & Mobile ─────────────────────────────────────────── */
.backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35); z-index: 90;
}
.backdrop.on { display: block; }

@media (max-width: 768px) {
  /* ── Base font scale ─────────────────────────── */
  body { font-size: 18px; }

  /* ── Sidebar overlay ─────────────────────────── */
  .sidebar {
    position: fixed; top: var(--header-h); bottom: 0; left: 0;
    z-index: 100; transform: translateX(-100%);
    transition: transform var(--transition);
    width: var(--sidebar-w) !important;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }

  /* ── Header ──────────────────────────────────── */
  .app-header { height: 56px; padding: 0 16px; }
  .app-name   { font-size: 18px; }
  .nav-btn    { font-size: 16px; padding: 8px 12px; }
  .nav-btn span.nav-label { display: none; }
  .btn-menu   { width: 38px; height: 38px; }

  /* ── Chat messages ───────────────────────────── */
  .msg-row    { padding: 5px 16px; }
  .tool-row   { padding: 4px 16px; }
  .typing-row { padding: 5px 16px; }
  .bubble     { max-width: 88%; font-size: 17px; }
  .msg-row.assistant .bubble { font-size: 17px; }
  .typing-dots span { width: 8px; height: 8px; }

  /* ── Input area — safe area aware ───────────────
     env(safe-area-inset-bottom) handles the iPhone
     home indicator / gesture bar.                  */
  .input-area {
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px)) 16px;
  }
  .input-wrap { height: 52px; border-radius: 12px; padding: 0 10px 0 16px; }
  #message-input { font-size: 17px; }
  .send-btn   { width: 38px; height: 38px; border-radius: 9px; }
  .icon-btn   { width: 38px; height: 38px; }
  .voice-preview { font-size: 15px; }

  /* ── Sidebar search ──────────────────────────── */
  .sidebar-search { height: 36px; font-size: 15px; }
  .actions-search { height: 44px; font-size: 17px; }

  /* ── Sidebar threads ─────────────────────────── */
  .sidebar-label  { font-size: 12px; }
  .thread-title   { font-size: 16px; }
  .thread-time    { font-size: 13px; }
  .btn-new-chat   { font-size: 16px; padding: 10px 12px; }

  /* ── Actions sidebar overlay ────────────────── */
  .actions-sidebar {
    position: fixed; top: var(--header-h); bottom: 0; left: 0;
    z-index: 100; transform: translateX(-100%);
    transition: transform var(--transition);
    width: var(--sidebar-w) !important;
    box-shadow: var(--shadow-md);
  }
  .actions-sidebar.open { transform: translateX(0); }
  .anav-btn { font-size: 18px; padding: 12px 14px; }

  /* ── Actions page ────────────────────────────── */
  .actions-page   { padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)) 16px; }
  .actions-title  { font-size: 22px; }
  .btn-add        { font-size: 16px; padding: 10px 16px; }
  .ftab           { font-size: 15px; padding: 7px 14px; }
  .item-row       { padding: 14px 16px; gap: 14px; }
  .item-name      { font-size: 17px; }
  .item-details   { gap: 8px; margin-top: 5px; }
  .pri-badge      { font-size: 12px; padding: 2px 9px; }
  .item-due,
  .item-desc      { font-size: 14px; }
  .item-id-badge  { font-size: 13px; }
  .item-actions   { opacity: 1; }
  .item-btn       { width: 36px; height: 36px; }

  /* Inline edit form */
  .edit-input,
  .edit-select    { height: 44px; font-size: 17px; }
  .edit-label     { font-size: 13px; }
  .edit-desc      { font-size: 16px; }
  .btn-cancel,
  .btn-save       { font-size: 16px; padding: 9px 18px; }
  .item-cb        { width: 22px; height: 22px; }
}

/* ─── Docs view ─────────────────────────────────────────────────── */
#view-docs { flex-direction: row; overflow: hidden; }

.docs-main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0; background: var(--surface);
}

/* ── Docs grid view ─────────────────────────────────────────────── */
.docs-grid-view {
  flex: 1; flex-direction: column; overflow-y: auto; background: var(--bg);
}
.docs-grid-header {
  padding: 24px 28px 16px; flex-shrink: 0;
}
.docs-grid-title {
  font-size: 18px; font-weight: 700; color: var(--text); margin: 0;
}
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  padding: 4px 28px 32px;
}
.docs-grid-empty {
  padding: 32px 28px; font-size: 13px; color: var(--text-faint);
}
.doc-card {
  aspect-ratio: 3 / 4;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.doc-card:hover {
  box-shadow: var(--shadow-md); transform: translateY(-2px);
}
.doc-card-header {
  padding: 10px 12px 6px; flex-shrink: 0;
  border-bottom: 1px solid var(--border-light);
}
.doc-card-title {
  font-size: 12px; font-weight: 600; color: var(--text);
  line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.doc-card-preview-wrap {
  flex: 1; overflow: hidden; position: relative;
}
.doc-card-preview-body {
  position: absolute; top: 0; left: 0;
  width: 560px;
  transform-origin: top left;
  pointer-events: none;
  padding: 10px 14px;
  font-size: 14px; line-height: 1.8; color: var(--text);
}
/* Hide interactive/edit elements inside preview */
.doc-card-preview-body .img-resize-handle { display: none; }
.doc-card-preview-body .file-card-dl { display: none; }
.doc-card-footer {
  padding: 8px 12px; border-top: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  gap: 4px; flex-shrink: 0; background: var(--bg);
}
.doc-card-project {
  font-size: 10px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px;
  padding: 1px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px;
}
.doc-card-date {
  font-size: 10px; color: var(--text-faint); flex-shrink: 0; white-space: nowrap;
}

/* Docs sidebar — mirrors .sidebar exactly */
.docs-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width var(--transition);
}
.docs-sidebar.collapsed { width: 0; border-right: none; }

/* Empty state */
.docs-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 24px; text-align: center; color: var(--text-muted);
}

/* Editor layout */
.docs-editor {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; height: 100%;
}

.docs-editor-header {
  display: flex; flex-direction: column; gap: 0;
  padding: 14px 24px 10px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.docs-editor-header-row {
  display: flex; align-items: center; gap: 10px;
}
.doc-props {
  display: flex; gap: 8px; margin-top: 7px;
}
.doc-prop-input {
  flex: 1; padding: 4px 9px; font-size: 12px; font-family: var(--font);
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); outline: none;
  transition: border-color var(--transition);
}
.doc-prop-input:focus { border-color: var(--accent); }
.doc-prop-input::placeholder { color: var(--text-faint); }

.doc-title-input {
  flex: 1; border: none; background: transparent; outline: none;
  font-family: var(--font); font-size: 17px; font-weight: 700;
  color: var(--text); letter-spacing: -0.02em;
  min-width: 0;
}
.doc-title-input::placeholder { color: var(--text-faint); font-weight: 400; }

.docs-editor-actions { display: flex; gap: 2px; flex-shrink: 0; }
.icon-btn.danger:hover { background: #fee2e2; color: #dc2626; }

/* Contenteditable body */
.doc-body {
  flex: 1; overflow-y: auto; outline: none;
  padding: 20px 28px;
  font-size: 14px; line-height: 1.8; color: var(--text);
  min-height: 0;
}
.doc-body::-webkit-scrollbar { width: 5px; }
.doc-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.doc-body:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint); pointer-events: none;
}

.doc-body.drag-over {
  background: var(--accent-soft);
  outline: 2px dashed var(--border);
  outline-offset: -4px;
}

/* ── Inline image wrapper ───────────────────────────────────── */
.doc-img-wrap {
  display: inline-block;
  position: relative;
  max-width: 100%;
  vertical-align: top;  /* keeps a row of images aligned at the top */
  /* no line-height:0 — keeping the natural line height lets the cursor
     remain visible when positioned before/after this element */
  margin: 2px 3px;
  cursor: default;
}
.doc-img-wrap.float-left  { float: left;  margin: 4px 16px 8px 0; }
.doc-img-wrap.float-right { float: right; margin: 4px 0 8px 16px; }
.doc-img-wrap.align-center { display: block; margin: 8px auto; float: none; }
.doc-img-wrap img {
  display: block; max-width: 100%; height: auto;
  border-radius: var(--radius-xs);
  pointer-events: none; /* let wrap receive events */
}
.doc-img-wrap.selected img { outline: 2px solid #3b82f6; border-radius: var(--radius-xs); }

/* drag-resize handle — bottom-right corner */
.img-resize-handle {
  position: absolute; bottom: 0; right: 0;
  width: 12px; height: 12px;
  background: #3b82f6; border-radius: 2px 0 3px 0;
  cursor: se-resize; opacity: 0;
  transition: opacity .12s;
  z-index: 2;
}
.doc-img-wrap:hover .img-resize-handle,
.doc-img-wrap.selected .img-resize-handle { opacity: 1; }

/* ── Floating image toolbar ─────────────────────────────────── */
#img-toolbar {
  position: fixed;
  display: none;
  align-items: center; gap: 1px;
  background: #1a1917;
  border-radius: 7px;
  padding: 4px 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  z-index: 400;
  transform: translateX(-50%);
  white-space: nowrap;
}
#img-toolbar button {
  background: transparent; border: none;
  color: rgba(255,255,255,.85); cursor: pointer;
  padding: 4px 7px; border-radius: 4px;
  font-size: 11px; font-weight: 500;
  font-family: var(--font);
  line-height: 1; transition: background .1s;
  display: flex; align-items: center; justify-content: center;
}
#img-toolbar button:hover  { background: rgba(255,255,255,.15); }
#img-toolbar button.active { background: rgba(255,255,255,.22); color: white; }
.img-toolbar-sep {
  width: 1px; height: 14px;
  background: rgba(255,255,255,.2);
  margin: 0 3px; flex-shrink: 0;
}

/* ── Inline file card ───────────────────────────────────────── */
.doc-file-card {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  max-width: 260px;
  cursor: default; user-select: none;
  vertical-align: middle;
  margin: 2px 2px;
  line-height: 1.3;
}
.file-card-icon { font-size: 18px; flex-shrink: 0; line-height: 1; }
.file-card-info { flex: 1; min-width: 0; }
.file-card-name {
  display: block; font-size: 12px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.file-card-size { display: block; font-size: 10px; color: var(--text-faint); margin-top: 1px; }
.file-card-dl {
  flex-shrink: 0; color: var(--text-muted); text-decoration: none;
  padding: 4px; border-radius: var(--radius-xs);
  display: flex; align-items: center;
  transition: background var(--transition);
}
.file-card-dl:hover { background: var(--accent-soft); color: var(--text); }

/* Doc footer */
.doc-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
  background: var(--surface);
}
.doc-meta { font-size: 12px; color: var(--text-faint); }
.doc-footer-btns { display: flex; align-items: center; gap: 6px; }

/* Chat attach preview strip */
.attach-preview {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 0 6px;
  max-width: 716px; margin: 0 auto;
}
.attach-preview:empty { display: none; padding: 0; }

.chat-attach-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px; border-radius: var(--radius-xs);
  border: 1px solid var(--border); background: var(--bg);
  font-size: 12px; max-width: 180px;
}
.chat-attach-chip > span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.chat-attach-thumb {
  width: 22px; height: 22px; object-fit: cover;
  border-radius: 3px; flex-shrink: 0;
}
.chat-attach-del {
  background: none; border: none; cursor: pointer;
  color: var(--text-faint); font-size: 14px; padding: 0;
  line-height: 1; flex-shrink: 0;
}
.chat-attach-del:hover { color: #dc2626; }

/* Chat message with file attachments */
.msg-user-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; max-width: 70%; }
.msg-files { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.msg-file-chip {
  padding: 3px 8px; border-radius: var(--radius-xs);
  border: 1px solid rgba(255,255,255,.2);
  font-size: 11px; color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.1);
}
.msg-img-thumb {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(255,255,255,.15);
}

/* ─── Doc footer link chips ──────────────────────────────────────── */
.doc-meta-text { color: var(--text-faint); font-size: 12px; }
.doc-meta-sep  { color: var(--text-faint); font-size: 12px; margin: 0 6px; }

.doc-links-row {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px;
}

.doc-link-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 5px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg);
  font-size: 11.5px; color: var(--text); text-decoration: none;
  white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis;
  transition: all var(--transition); cursor: pointer;
}
.doc-link-chip:hover { background: var(--text); color: white; border-color: var(--text); }
.doc-link-chip:hover .doc-link-chip-dot { opacity: 0.7; }
.doc-link-chip.done { opacity: 0.5; text-decoration: line-through; }

.doc-link-chip-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.doc-link-chip-dot.high   { background: #ef4444; }
.doc-link-chip-dot.medium { background: #f59e0b; }
.doc-link-chip-dot.low    { background: #22c55e; }

.doc-links-more {
  font-size: 11px; color: var(--text-muted); padding: 2px 7px;
  border: 1px solid var(--border); border-radius: 10px; background: transparent;
  cursor: pointer; font-family: var(--font); transition: all var(--transition);
}
.doc-links-more:hover { background: var(--text); color: white; border-color: var(--text); }

/* Link panel rows (inside modal, view-all mode) */
.link-panel-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 18px; cursor: pointer;
  transition: background var(--transition);
}
.link-panel-item:hover { background: var(--accent-soft); }
.link-panel-info { flex: 1; min-width: 0; }
.link-panel-title {
  font-size: 13px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.link-panel-title.done { text-decoration: line-through; color: var(--text-muted); }
.link-panel-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; }

/* ─── Action item linked-doc chips ───────────────────────────────── */
.item-doc-links {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px;
}

.item-doc-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 10px;
  border: 1px solid var(--border-light); background: var(--surface);
  font-size: 11px; color: var(--text-muted); text-decoration: none;
  white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis;
  transition: all var(--transition);
}
.item-doc-chip::before {
  content: '';
  display: inline-block; width: 10px; height: 10px; flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3C/svg%3E");
  background-size: contain; background-repeat: no-repeat;
}
.item-doc-chip:hover {
  background: var(--accent-soft); color: var(--text); border-color: var(--border);
}

.item-doc-more {
  font-size: 11px; color: var(--text-faint); padding: 2px 6px;
  border: 1px solid var(--border-light); border-radius: 10px;
}

/* ── Inline comments ───────────────────────────────────────────── */
.item-comments-wrap { margin-top: 7px; display: flex; flex-direction: column; gap: 3px; }
.icmt-more          { font-size: 11px; color: var(--text-faint); padding: 0 2px 1px; }

/* Single-line comment row */
.icmt-line {
  display: flex; align-items: center; gap: 4px;
  background: var(--sidebar-bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 8px 4px 10px;
  font-size: 12px; line-height: 1; min-height: 26px;
}
.icmt-meta  { font-weight: 600; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.icmt-sep   { color: var(--text-faint); flex-shrink: 0; }
.icmt-text  { color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Edit/delete icons — appear on hover */
.icmt-line-actions { display: flex; gap: 1px; opacity: 0; transition: opacity var(--transition); margin-left: auto; flex-shrink: 0; }
.icmt-line:hover .icmt-line-actions { opacity: 1; }
.icmt-line-actions-always           { opacity: 1; }   /* compose / edit always visible */

.icmt-action-btn {
  width: 20px; height: 20px; border-radius: 50%; border: none;
  background: transparent; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition); flex-shrink: 0;
}
.icmt-action-btn:hover    { background: var(--border); color: var(--text); }
.icmt-delete-btn:hover    { background: #fecaca; color: #b91c1c; }
.icmt-post-btn            { background: var(--accent-soft); color: var(--accent); }
.icmt-post-btn:hover      { background: var(--accent); color: var(--bg); }

/* Compose / edit line */
.icmt-compose-line { border-style: dashed; gap: 0; }
.icmt-date-input {
  background: transparent; border: none; outline: none;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  font-family: var(--font); min-width: 0; flex-shrink: 0;
}
.icmt-date-input::placeholder { font-weight: 400; color: var(--text-faint); }
.icmt-author-inline {
  background: transparent; border: none; outline: none;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  font-family: var(--font); min-width: 0; flex-shrink: 0; margin-left: 4px;
}
.icmt-author-inline::placeholder { font-weight: 400; color: var(--text-faint); }
.icmt-sep { color: var(--text-faint); flex-shrink: 0; margin: 0 2px 0 0; }
.icmt-compose-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: 12px; color: var(--text); font-family: var(--font);
}
.icmt-compose-input::placeholder { color: var(--text-faint); }

/* ── Breakdown share button ─────────────────────────────────────── */
.breakdown-share-btn {
  width: 26px; height: 26px; border-radius: 6px; border: none;
  background: transparent; color: var(--text-faint); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  opacity: 0; transition: opacity var(--transition), background var(--transition);
}
.breakdown-row:hover .breakdown-share-btn { opacity: 1; }
.breakdown-share-btn:hover { background: var(--accent-soft); color: var(--accent); }

/* ── Share project modal ─────────────────────────────────────────── */
.share-modal  { max-width: 420px; }
.share-body   { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.share-project-name { font-size: 15px; font-weight: 600; color: var(--text); }
.share-desc   { font-size: 13px; color: var(--text-muted); margin: 0; line-height: 1.5; }
.share-link-row { display: flex; gap: 8px; }
.share-link-input {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--text);
  outline: none; font-family: var(--font); cursor: text;
}
.share-generating { font-size: 12px; color: var(--text-faint); }

/* ── Settings modal ─────────────────────────────────────────────── */
.settings-modal { max-width: 380px; }
.settings-body  { padding: 20px 20px 4px; display: flex; flex-direction: column; gap: 20px; }
.settings-group { display: flex; flex-direction: column; gap: 8px; }
.settings-label { font-size: 13px; font-weight: 500; color: var(--text); }
.settings-input-row { display: flex; align-items: center; gap: 10px; }
.settings-num-input {
  width: 72px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 14px; color: var(--text);
  outline: none; text-align: center; font-family: var(--font);
}
.settings-num-input:focus { border-color: var(--accent); }
.settings-unit { font-size: 13px; color: var(--text-muted); }
.settings-hint { font-size: 11px; color: var(--text-faint); }

/* Link modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 300;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  width: min(460px, calc(100vw - 32px));
  max-height: 70dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: fadeIn .15s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.modal-title { font-size: 14px; font-weight: 600; }
.modal-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.modal-body.search-modal { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.modal-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end;
  flex-shrink: 0;
}

.modal-search-wrap { padding: 10px 14px 6px; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.modal-search {
  width: 100%; padding: 7px 10px; font-size: 13px;
  background: var(--sidebar); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); outline: none;
  box-sizing: border-box;
}
.modal-search:focus { border-color: var(--accent); }
.link-modal-results { flex: 1; overflow-y: auto; }

.link-item {
  display: flex; align-items: center;
  padding: 9px 18px;
  gap: 10px; cursor: pointer;
  transition: background var(--transition);
}
.link-item:hover { background: var(--accent-soft); }
.link-item input[type="checkbox"] { flex-shrink: 0; accent-color: var(--text); width: 15px; height: 15px; }
.link-item-title { flex: 1; font-size: 13px; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-item-time  { font-size: 11px; color: var(--text-faint); flex-shrink: 0; }

/* Mobile overrides for calendar */
@media (max-width: 768px) {
  .cal-header { padding: 14px 16px 10px; gap: 8px; }
  #cal-title  { font-size: 15px; min-width: 0; flex: 1; }
  .cal-month  { padding: 0 12px 16px; }
  .cal-week   { padding: 0 12px 16px; }
  .cal-day    { padding: 0 12px 16px; }
  .cal-week-row { min-height: 70px; }
  .cal-day-cell { min-height: 70px; }
  .cal-week-col { min-width: 60px; }
  .cal-view-tabs .ftab { font-size: 13px; padding: 5px 10px; }
}

/* Mobile overrides for docs */
@media (max-width: 768px) {
  .docs-sidebar {
    position: fixed; top: var(--header-h); bottom: 0; left: 0;
    z-index: 100; transform: translateX(-100%);
    transition: transform var(--transition);
    width: var(--sidebar-w) !important;
    box-shadow: var(--shadow-md);
  }
  .docs-sidebar.open { transform: translateX(0); }

  .docs-editor-header { padding: 12px 16px 10px; }
  .doc-title-input { font-size: 20px; }
  .doc-body { padding: 16px; font-size: 17px; line-height: 1.75; }
  .doc-footer { padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 0px)); }
}

/* ─── Animations ────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.25; }
  40%           { opacity: 1; }
}
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.25); }
  50%       { box-shadow: 0 0 0 5px rgba(220,38,38,0); }
}

/* ════════════════════════════════════════════════════════════════
   HOME VIEW
   ════════════════════════════════════════════════════════════════ */
#view-home.active { overflow: hidden; }

/* Home sidebar */
.home-sidebar {
  width: 220px; min-width: 220px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
  transition: width var(--transition), min-width var(--transition);
}
.home-sidebar.collapsed { width: 0; min-width: 0; border-right: none; overflow: hidden; }

/* Home main */
.home-main { flex: 1; overflow-y: auto; }
.home-wrap {
  max-width: 760px; margin: 0 auto;
  padding: 32px 24px 60px;
}
.home-header { margin-bottom: 24px; }
.home-title  { font-size: 22px; font-weight: 700; color: var(--text); margin: 0; }

/* Sidebar filter sections */
.hf-section  { margin-bottom: 4px; }
.hf-chips    { padding: 4px 10px 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.hf-empty    { font-size: 12px; color: var(--text-faint); padding: 4px 2px; }
.hf-clear-btn {
  margin: 4px 10px 8px; padding: 5px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); font-size: 12px; cursor: pointer; width: calc(100% - 20px);
}
.hf-clear-btn:hover { background: var(--accent-soft); }

/* Filter section */
.home-filters-section { margin-bottom: 28px; }
.home-filter-block    { margin-bottom: 16px; }
.home-filter-label    { font-size: 11px; font-weight: 600; color: var(--text-muted);
                         text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.home-filter-chips    { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-chip {
  padding: 5px 13px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px;
  cursor: pointer; transition: background var(--transition), border-color var(--transition);
}
.filter-chip:hover  { background: var(--accent-soft); border-color: var(--accent); }
.filter-chip.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.filter-none        { font-size: 13px; color: var(--text-faint); }
.filter-clear-btn {
  margin-top: 12px; padding: 5px 13px; border-radius: 6px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); font-size: 12px; cursor: pointer;
}
.filter-clear-btn:hover { background: var(--accent-soft); }

/* Stats cards */
.home-stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 32px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 16px; text-align: center;
}
.stat-card.danger  { border-color: #e57373; }
.stat-card.success { border-color: #66bb6a; }
.stat-num   { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card.danger  .stat-num { color: #e57373; }
.stat-card.success .stat-num { color: #66bb6a; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* Breakdown */
.home-breakdown        { }
.home-breakdown-title  { font-size: 13px; font-weight: 600; color: var(--text-muted);
                          text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.home-breakdown-empty  { font-size: 13px; color: var(--text-faint); }
.breakdown-list        { display: flex; flex-direction: column; gap: 10px; }
.breakdown-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; transition: background var(--transition);
}
.breakdown-row:hover   { background: var(--accent-soft); }
.breakdown-proj        { font-size: 13px; font-weight: 500; color: var(--text); width: 140px; flex-shrink: 0;
                          white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breakdown-bar-wrap    { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.breakdown-bar         { height: 100%; background: var(--accent); border-radius: 3px; min-width: 2px; transition: width .4s; }
.breakdown-counts      { display: flex; gap: 8px; flex-shrink: 0; }
.breakdown-pending     { font-size: 12px; color: var(--text-muted); }
.breakdown-done        { font-size: 12px; color: #66bb6a; }

/* Item badges */
.item-project-badge {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 10px; font-weight: 600; background: var(--accent-soft);
  color: var(--accent); border: 1px solid var(--accent); white-space: nowrap;
}
.item-owner-chip {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 10px; background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border); white-space: nowrap;
}

/* Global filter banner */
.filter-banner {
  display: none; align-items: center; justify-content: space-between;
  padding: 7px 16px; background: var(--accent-soft); border-bottom: 1px solid var(--accent);
  font-size: 12px; color: var(--text); flex-shrink: 0;
}
.filter-banner-clear {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: 12px; padding: 0 4px;
}
.filter-banner-clear:hover { color: var(--text); }

@media (max-width: 600px) {
  .home-stats-row { grid-template-columns: repeat(2, 1fr); }
  .breakdown-proj { width: 90px; }
}


/* Mobile: home sidebar slides in from left */
@media (max-width: 768px) {
  .home-sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0;
    z-index: 200; width: 260px; min-width: 260px;
    background: var(--bg); border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform var(--transition);
  }
  .home-sidebar.open      { transform: translateX(0); }
  .home-sidebar.collapsed { width: 260px; min-width: 260px; transform: translateX(-100%); }
  .home-main { overflow-y: auto; }
  .home-stats-row { grid-template-columns: repeat(2, 1fr); }
  .breakdown-proj { width: 90px; }
}

/* ════════════════════════════════════════════════════════════════
   DOCS — VIEW MODE
   ════════════════════════════════════════════════════════════════ */

/* Hide edit-only controls in view mode */
.docs-editor.view-mode .edit-only { display: none !important; }

/* Edit button active state (while in edit mode) */
#doc-edit-btn.active { background: var(--accent-soft); color: var(--accent); }

/* Make title + props look like plain text in view mode */
.docs-editor.view-mode .doc-title-input,
.docs-editor.view-mode .doc-prop-input {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
  cursor: default;
}

/* Suppress placeholder in view mode */
.docs-editor.view-mode .doc-body:empty::before { display: none; }

/* Hide resize handle and make images / file cards clickable in view mode */
.docs-editor.view-mode .img-resize-handle { display: none; }
.docs-editor.view-mode .doc-img-wrap { cursor: zoom-in; }
.docs-editor.view-mode .doc-file-card { cursor: pointer; }
.docs-editor.view-mode .file-card-dl { display: none; }

/* ════════════════════════════════════════════════════════════════
   MEDIA LIGHTBOX
   ════════════════════════════════════════════════════════════════ */
.lightbox-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 3000;
  display: flex; align-items: center; justify-content: center;
}

.lightbox-box {
  position: relative;
  display: flex; flex-direction: column;
  max-width: min(92vw, 1100px);
  max-height: 92vh;
  width: 100%;
}

.lightbox-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px 10px;
  flex-shrink: 0;
}
.lightbox-counter {
  font-size: 13px; color: rgba(255,255,255,.6);
  min-width: 40px;
}
.lightbox-toolbar-btns { display: flex; gap: 4px; }
.lightbox-toolbar-btns .icon-btn {
  color: rgba(255,255,255,.75);
  background: rgba(255,255,255,.08);
}
.lightbox-toolbar-btns .icon-btn:hover { background: rgba(255,255,255,.18); color: #fff; }

.lightbox-content {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

.lightbox-img {
  max-width: 100%; max-height: calc(92vh - 100px);
  object-fit: contain;
  border-radius: var(--radius-sm);
  display: block;
}

/* File view inside lightbox */
.lightbox-file {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 32px 24px;
  text-align: center; color: #fff;
}
.lightbox-file-icon { font-size: 48px; line-height: 1; }
.lightbox-file-icon svg { width: 48px; height: 48px; stroke: rgba(255,255,255,.7); }
.lightbox-file-name { font-size: 16px; font-weight: 600; word-break: break-all; max-width: 400px; }
.lightbox-file-size { font-size: 13px; color: rgba(255,255,255,.5); }
.lightbox-file-dl {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 8px; padding: 10px 22px;
  background: rgba(255,255,255,.12); border-radius: var(--radius-sm);
  color: #fff; font-size: 14px; font-weight: 500;
  text-decoration: none; transition: background .15s;
}
.lightbox-file-dl:hover { background: rgba(255,255,255,.22); }

/* Prev / Next nav buttons */
.lightbox-nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.1); border: none;
  color: rgba(255,255,255,.8); cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; z-index: 1;
}
.lightbox-nav-btn:hover { background: rgba(255,255,255,.22); color: #fff; }
.lightbox-prev { left: -52px; }
.lightbox-next { right: -52px; }

@media (max-width: 768px) {
  .lightbox-prev { left: 4px; }
  .lightbox-next { right: 4px; }
  .lightbox-box  { max-width: 100vw; max-height: 100vh; border-radius: 0; }
}

/* ─── Tool mode popover ──────────────────────────────────────────── */
.tool-mode-wrap {
  position: relative;
}

.tool-mode-btn.tool-mode-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.tool-mode-popover {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  overflow: hidden;
}
.tool-mode-popover.open { display: block; }

.tmp-option {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.tmp-option:last-child { border-bottom: none; }
.tmp-option:hover { background: var(--bg); }
.tmp-option.active { background: var(--accent-soft); }

.tmp-label {
  display: block;
  font-size: 13px; font-weight: 500; color: var(--text);
  line-height: 1.3;
}
.tmp-desc {
  display: block;
  font-size: 11px; color: var(--text-faint);
  margin-top: 1px;
}
.tmp-option.active .tmp-label { color: var(--accent); }

/* ─── Actions filter panel ───────────────────────────────────────── */
#actions-filter-btn.active { background: var(--accent-soft); color: var(--accent); }

.filter-active-dot {
  position: absolute; top: 4px; right: 4px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}

.actions-filter-panel {
  flex-shrink: 0;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.22s ease, padding 0.22s ease;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0;
}
.actions-filter-panel.open {
  max-height: 260px;
  margin-bottom: 12px;
  padding: 12px 14px;
}

.af-section { margin-bottom: 10px; }
.af-section:last-child { margin-bottom: 0; }

.af-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.af-chips { display: flex; flex-wrap: wrap; gap: 5px; }

.af-chip {
  padding: 3px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px; font-family: var(--font);
  cursor: pointer; transition: all var(--transition);
}
.af-chip:hover { border-color: var(--text); color: var(--text); }
.af-chip.selected { border-color: var(--accent); background: var(--accent); color: #fff; }

.af-empty { font-size: 12px; color: var(--text-faint); font-style: italic; }

.af-clear-wrap { padding-top: 8px; border-top: 1px solid var(--border-light); margin-top: 4px; }
.af-clear {
  background: none; border: none;
  font-size: 12px; font-family: var(--font);
  color: var(--text-muted); cursor: pointer; padding: 0;
  transition: color var(--transition);
}
.af-clear:hover { color: var(--text); }

/* ─── Item detail page ───────────────────────────────────────────── */
.item-name-link {
  cursor: pointer;
  transition: color var(--transition);
}
.item-name-link:hover { color: var(--text-muted); text-decoration: underline; }

.atab-item-detail {
  display: none; flex: 1; flex-direction: column; overflow: hidden;
}
.atab-item-detail.active { display: flex; }

.item-detail-page {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
  max-width: 760px; width: 100%; margin: 0 auto;
  padding: 20px 28px 20px;
}

.item-detail-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 20px; flex-shrink: 0;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 14px;
}

.item-detail-back {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-xs);
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; flex-shrink: 0;
  transition: all var(--transition);
}
.item-detail-back:hover { background: var(--border); color: var(--text); }

.item-detail-title {
  font-size: 14px; font-weight: 600; color: var(--text);
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.item-detail-counter {
  font-size: 12px; color: var(--text-faint);
  white-space: nowrap; flex-shrink: 0;
}

.item-detail-nav {
  display: flex; gap: 2px; flex-shrink: 0;
}
.item-detail-nav-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-xs);
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; transition: all var(--transition);
}
.item-detail-nav-btn:hover { background: var(--border); color: var(--text); }
.item-detail-nav-btn:disabled { opacity: 0.3; cursor: default; }

.item-detail-header-btns {
  display: flex; gap: 4px; flex-shrink: 0;
  padding-left: 8px;
  border-left: 1px solid var(--border-light);
}

.item-detail-body {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0;
}
.item-detail-body::-webkit-scrollbar { width: 5px; }
.item-detail-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Main item card */
.detail-item-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
}

.detail-cb-row {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 12px;
}
.detail-cb-row .item-cb { margin-top: 3px; }

.detail-title {
  font-size: 18px; font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.35; flex: 1; min-width: 0;
  color: var(--text);
}
.detail-title.completed { text-decoration: line-through; color: var(--text-muted); }

.detail-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 12px;
}

.detail-desc {
  font-size: 13.5px; color: var(--text-muted);
  line-height: 1.65; white-space: pre-wrap;
  margin-top: 4px;
}

/* Sections (comments, docs) */
.detail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.detail-section:last-child { margin-bottom: 0; }

.detail-section-title {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* Comments */
.detail-comments { display: flex; flex-direction: column; gap: 12px; }

.detail-comment {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}
.detail-comment:last-child { border-bottom: none; padding-bottom: 0; }

.detail-comment-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.detail-comment-author {
  font-size: 12px; font-weight: 600; color: var(--text);
}
.detail-comment-time {
  font-size: 11px; color: var(--text-faint);
}

.detail-comment-text {
  font-size: 13px; color: var(--text-muted);
  line-height: 1.55; white-space: pre-wrap;
}

/* Linked doc cards inside detail */
.detail-doc-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 10px;
}
.detail-doc-card:last-child { margin-bottom: 0; }

.detail-doc-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
}

.detail-doc-body {
  padding: 12px 14px;
  max-height: 320px;
  overflow-y: auto;
  font-size: 13px; line-height: 1.6;
}
.detail-doc-body::-webkit-scrollbar { width: 4px; }
.detail-doc-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Loading / empty states */
.detail-loading, .detail-empty {
  display: flex; align-items: center; justify-content: center;
  padding: 32px; color: var(--text-faint);
  font-size: 13px; font-style: italic;
}

@media (max-width: 768px) {
  .item-detail-page { padding: 14px 14px 12px; }
  .item-detail-header { margin-bottom: 14px; }
  .detail-item-main { padding: 14px 14px; }
  .detail-doc-body { max-height: 220px; }
}
