/* ═══════════════════════════════════════
   THOT — layout.css
   App shell, sidebar, topbar, content area
═══════════════════════════════════════ */

/* ── APP SHELL ── */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--t-slow);
  z-index: 100;
  overflow: hidden;
}

.sidebar-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px 0 18px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-shrink: 0;
}

.logo {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: .02em;
  color: var(--text);
  flex: 1;
  line-height: 1;
}
.logo span { color: var(--accent); }

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Today + Inbox links */
.sidebar-today {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  text-decoration: none;
}
.sidebar-today:hover { background: var(--bg); color: var(--text); }
.sidebar-today.active { background: var(--accent-lt); color: var(--accent); font-weight: 500; }
.sidebar-today svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--muted); }
.sidebar-today.active svg { color: var(--accent); }
.sidebar-today span:nth-child(2) { flex: 1; }
.today-badge {
  font-size: 10px;
  font-weight: 600;
  min-width: 18px;
  height: 16px;
  padding: 0 4px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
  flex-shrink: 0;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  padding: 4px 10px 2px;
}
.sidebar-label {
  flex: 1;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── SPACE ITEMS ── */
.space-item { flex-shrink: 0; }

.space-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background var(--t-fast);
  position: relative;
}
.space-row:hover { background: var(--bg); }
.space-row:hover .space-actions { opacity: 1; }

.space-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--accent); }
.space-name { flex: 1; font-size: 13.5px; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-chevron {
  width: 13px; height: 13px;
  color: var(--muted-lt);
  transition: transform var(--t-base);
  flex-shrink: 0;
}
.space-item.open .space-chevron { transform: rotate(90deg); }

.space-actions {
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity var(--t-fast);
}

/* ── PAGE LIST ── */
.page-list {
  padding: 2px 0 4px 20px;
  display: none;
  flex-direction: column;
  gap: 1px;
}
.space-item.open .page-list { display: flex; }

.page-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast);
  position: relative;
}
.page-row:hover { background: var(--bg); }
.page-row:hover .page-actions { opacity: 1; }
.page-row.active { background: var(--accent-lt); }

.page-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--muted-lt);
  flex-shrink: 0;
}
.page-row.active .page-dot { background: var(--accent); }

.page-name {
  flex: 1;
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-row.active .page-name { color: var(--accent); font-weight: 500; }

.page-actions {
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity var(--t-fast);
}

/* ── SUBPAGE LIST ── */
.subpage-list {
  padding: 2px 0 2px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.subpage-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.subpage-row:hover { background: var(--bg); color: var(--text); }
.subpage-row.active { color: var(--accent); background: var(--accent-lt); }
.subpage-arrow { font-size: 10px; opacity: .5; }

/* ── SIDEBAR FOOTER ── */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 8px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-footer-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-footer-link:hover { background: var(--bg); color: var(--text); }
.sidebar-footer-link svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ── MAIN ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── TOPBAR ── */
.topbar {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
  background: var(--surface);
  flex-shrink: 0;
}

.btn-menu {
  display: none;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.btn-menu:hover { background: var(--bg); color: var(--text); }
.btn-menu svg { width: 18px; height: 18px; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.breadcrumb > * { white-space: nowrap; }
.bc-sep { opacity: .35; font-size: 12px; }
.bc-space { overflow: hidden; text-overflow: ellipsis; }
.bc-page { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.bc-home { color: var(--text-2); font-family: var(--font-serif); font-style: italic; font-size: 16px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

/* ── VIEW / CONTENT ── */
.view {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

/* ── PAGE CONTENT LAYOUT ── */
.page-content {
  padding: 32px 36px 80px;
  max-width: 1200px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 24px;
}

.page-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
}

.page-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 24px;
}

/* ── TWO COLUMN LAYOUT ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 18px;
  align-items: start;
}
.col-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.col-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ── VIEW EMPTY STATE ── */
.view-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px;
  text-align: center;
}
.empty-logo {
  font-family: var(--font-serif);
  font-size: 64px;
  font-style: italic;
  font-weight: 300;
  color: var(--border);
  line-height: 1;
}
.empty-logo span { color: var(--accent-md); }
.empty-sub { font-size: 14px; color: var(--muted); margin-top: -4px; }

/* ── TODAY VIEW ── */
.today-view { padding: 32px 36px 80px; }
.today-date {
  font-family: var(--font-serif);
  font-size: 13px;
  font-style: italic;
  color: var(--muted);
  margin-bottom: 6px;
}
.today-title {
  font-family: var(--font-serif);
  font-size: 34px;
  font-style: italic;
  font-weight: 400;
  margin-bottom: 28px;
}

.today-group { margin-bottom: 24px; }
.today-group-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  padding-left: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.today-group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── INBOX VIEW ── */
.inbox-view { padding: 32px 36px 80px; }
.inbox-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: box-shadow var(--t-fast);
}
.inbox-item:hover { box-shadow: var(--shadow-sm); }
.inbox-item-text { flex: 1; font-size: 13.5px; line-height: 1.5; }
.inbox-item-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.inbox-item-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--t-fast); }
.inbox-item:hover .inbox-item-actions { opacity: 1; }

/* ── ARCHIVE VIEW ── */
.archive-view { padding: 32px 36px 80px; }
.archive-section { margin-bottom: 32px; }
.archive-section-title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── QUICK CAPTURE ── */
.qc-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(42,37,32,.3);
  backdrop-filter: blur(3px);
  z-index: 800;
  display: none;
  animation: fadeIn var(--t-fast);
}
.qc-backdrop.open { display: block; }

.qc-modal {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 560px;
  max-width: calc(100vw - 32px);
  z-index: 801;
  display: none;
}
.qc-modal.open { display: block; animation: modalIn var(--t-base); }

.qc-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}

.qc-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 15px;
  font-family: var(--font-sans);
  color: var(--text);
  border: none;
  outline: none;
  background: transparent;
  border-bottom: 1px solid var(--border);
}
.qc-input::placeholder { color: var(--muted-lt); }

.qc-results {
  max-height: 300px;
  overflow-y: auto;
}

.qc-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background var(--t-fast);
  font-size: 13.5px;
}
.qc-result-item:hover, .qc-result-item.selected { background: var(--accent-lt); }
.qc-result-icon { font-size: 14px; flex-shrink: 0; }
.qc-result-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qc-result-meta { font-size: 11px; color: var(--muted); white-space: nowrap; }

.qc-section-label {
  padding: 8px 20px 4px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.qc-footer {
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.qc-hint {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* ── SIDEBAR OVERLAY (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(42,37,32,.4);
  backdrop-filter: blur(2px);
  z-index: 99;
}

/* ═══════════════════════════════════════
   TODO DETAIL PANEL
═══════════════════════════════════════ */
.tdp-overlay {
  position: fixed; inset: 0;
  background: rgba(42,37,32,.18);
  backdrop-filter: blur(1px);
  z-index: 600; opacity: 0; pointer-events: none;
  transition: opacity .22s ease;
}
.tdp-overlay.open { opacity: 1; pointer-events: auto; }

.tdp {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 34vw; min-width: 340px; max-width: 520px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 32px rgba(42,37,32,.12);
  z-index: 601; display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .24s cubic-bezier(.32,.72,0,1);
  overflow: hidden;
}
.tdp.open { transform: translateX(0); }

.tdp-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 13px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; background: var(--surface-2);
}
.tdp-page-crumb {
  font-size: 11.5px; color: var(--muted);
  display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0;
}
.tdp-page-crumb .sep { opacity: .4; flex-shrink: 0; }

.btn-tdp-close {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); flex-shrink: 0; border: none; background: none;
  cursor: pointer; transition: background var(--t), color var(--t);
}
.btn-tdp-close:hover { background: var(--bg); color: var(--text); }
.btn-tdp-close svg { width: 14px; height: 14px; }

.tdp-title-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 16px 16px 12px; flex-shrink: 0;
}
.tdp-check {
  width: 17px; height: 17px; border-radius: 5px;
  border: 1.5px solid var(--border); flex-shrink: 0;
  cursor: pointer; appearance: none; -webkit-appearance: none;
  background: white; position: relative; transition: all var(--t); margin-top: 3px;
}
.tdp-check:checked { background: var(--accent); border-color: var(--accent); }
.tdp-check:checked::after { content:''; position:absolute; left:3px; top:1px; width:6px; height:8px; border:2px solid white; border-top:none; border-left:none; transform:rotate(45deg); }

.tdp-title {
  flex: 1; font-family: var(--font-serif);
  font-size: 20px; font-style: italic; font-weight: 400;
  line-height: 1.3; outline: none; border: none;
  background: transparent; color: var(--text);
  resize: none; min-height: 28px; width: 100%; font-family: inherit;
}
.tdp-title.done { text-decoration: line-through; color: var(--muted); }

.tdp-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 0 16px 14px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.tdp-meta-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; padding: 4px 9px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text-2); cursor: pointer; transition: all var(--t); white-space: nowrap;
}
.tdp-meta-pill:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-lt); }
.tdp-meta-pill svg { width: 11px; height: 11px; }
.tdp-meta-pill.active-today   { background: #FEE8E4; color: var(--danger); border-color: #F0C0B4; }
.tdp-meta-pill.active-soon    { background: var(--warn-lt); color: var(--warn); border-color: var(--warn-bd); }
.tdp-meta-pill.active-someday { background: var(--bg); color: var(--muted); border-color: var(--border); }

.tdp-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }

.tdp-section-label {
  font-size: 10px; font-weight: 500; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}

.tdp-editor {
  min-height: 120px; outline: none;
  font-size: 13.5px; line-height: 1.75; color: var(--text-2);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 12px; transition: border-color var(--t), background var(--t);
}
.tdp-editor:focus { border-color: var(--accent-md); background: var(--bg); }
.tdp-editor:empty::before { content: attr(data-placeholder); color: var(--muted-lt); pointer-events: none; }

.tdp-subtask-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: var(--radius-sm); transition: background var(--t);
}
.tdp-subtask-item:hover { background: var(--bg); }
.tdp-subtask-check {
  width: 13px; height: 13px; border-radius: 3px;
  border: 1.5px solid var(--border); flex-shrink: 0;
  appearance: none; -webkit-appearance: none;
  background: white; position: relative; cursor: pointer; transition: all var(--t);
}
.tdp-subtask-check:checked { background: var(--accent); border-color: var(--accent); }
.tdp-subtask-check:checked::after { content:''; position:absolute; left:2px; top:0; width:5px; height:7px; border:2px solid white; border-top:none; border-left:none; transform:rotate(45deg); }
.tdp-subtask-text {
  flex: 1; font-size: 13px; outline: none; border: none;
  background: transparent; color: var(--text); font-family: var(--font-sans);
}

.tdp-add-subtask {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; font-size: 12.5px; color: var(--muted-lt);
  cursor: pointer; border-radius: var(--radius-sm);
  transition: background var(--t), color var(--t);
}
.tdp-add-subtask:hover { background: var(--bg); color: var(--accent); }
.tdp-add-subtask svg { width: 11px; height: 11px; }

.tdp-date-input {
  font-family: var(--font-sans); font-size: 13px; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 10px; background: var(--bg); outline: none;
  transition: border-color var(--t);
}
.tdp-date-input:focus { border-color: var(--accent); }

.tdp-footer {
  padding: 10px 16px; border-top: 1px solid var(--border);
  background: var(--surface-2); display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.tdp-save-hint { font-size: 11px; color: var(--muted); flex: 1; font-family: var(--font-mono); }

.btn-ics {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 500; padding: 5px 11px; border-radius: 20px;
  border: 1px solid var(--accent-md); background: var(--accent-lt); color: var(--accent);
  cursor: pointer; transition: all var(--t); white-space: nowrap;
}
.btn-ics:hover { background: var(--accent-md); border-color: var(--accent); }
.btn-ics svg { width: 11px; height: 11px; }

.btn-ics-sm {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 500; padding: 2px 6px; border-radius: 8px;
  border: 1px solid var(--accent-md); background: var(--accent-lt); color: var(--accent);
  cursor: pointer; transition: all var(--t); vertical-align: middle;
}
.btn-ics-sm:hover { background: var(--accent-md); }
.btn-ics-sm svg { width: 9px; height: 9px; }
