/* ──────────────────────────────────────────────────────────
   Claude Remote — Soft UI Cream / Cozy Tech
   Palette: cream white · lavender · morandi
   ─────────────────────────────────────────────────────────── */

:root {
  --cream:        #F8F4ED;
  --cream-soft:   #FDFAF4;
  --cream-warm:   #F2ECE0;
  --paper:        #FFFFFF;

  --ink:          #2D2A26;
  --ink-2:        #5C554C;
  --ink-3:        #8C8478;
  --ink-4:        #B8B0A4;

  --lavender:     #B8A4D9;
  --lavender-2:   #9B82C4;
  --lavender-soft:#EBE3F5;
  --lavender-bg:  #F5F0FB;

  --sage:         #B5C5B0;
  --rose:         #E0C4BE;
  --peach:        #F0D6BC;
  --sand:         #DCD0BC;

  --line:         rgba(120, 100, 80, 0.08);
  --line-2:       rgba(120, 100, 80, 0.14);

  --shadow-xs:    0 1px 2px rgba(120, 100, 80, 0.04);
  --shadow-sm:    0 2px 6px rgba(120, 100, 80, 0.05), 0 1px 2px rgba(120, 100, 80, 0.03);
  --shadow-md:    0 8px 24px rgba(120, 100, 80, 0.07), 0 2px 6px rgba(120, 100, 80, 0.04);
  --shadow-lg:    0 16px 48px rgba(120, 100, 80, 0.10), 0 4px 12px rgba(120, 100, 80, 0.05);
  --shadow-inset: inset 1px 1px 2px rgba(0,0,0,0.025), inset -1px -1px 2px rgba(255,255,255,0.9);

  --r-xl:  28px;
  --r-lg:  22px;
  --r-md:  18px;
  --r-sm:  14px;

  --gap:   16px;

  --font:  'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans CJK SC', sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12% -8%,  rgba(184, 164, 217, 0.22) 0%, transparent 38%),
    radial-gradient(circle at 96% 0%,   rgba(224, 196, 190, 0.20) 0%, transparent 36%),
    radial-gradient(circle at 50% 110%, rgba(181, 197, 176, 0.14) 0%, transparent 42%),
    var(--cream);
  background-attachment: fixed;
}

button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { border: none; background: none; cursor: pointer; }
input, textarea { border: none; outline: none; background: transparent; }

.hidden { display: none !important; }

/* ── Layout primitives ───────────────────────────────────── */

.view {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 18px calc(env(safe-area-inset-bottom) + 18px);
  min-height: 100vh;
  min-height: 100dvh;
}

.floating {
  background: var(--paper);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line);
}

/* ── Login ──────────────────────────────────────────────── */

.view-login {
  display: flex; align-items: center; justify-content: center;
  padding-top: max(40px, env(safe-area-inset-top));
}

.login-card {
  width: 100%;
  padding: 36px 28px 24px;
  border-radius: var(--r-xl);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0.95) 100%),
    var(--paper);
}

.brand { text-align: center; margin-bottom: 28px; }

.brand-mark {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  width: 60px; height: 60px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: linear-gradient(145deg, #FFFFFF, #F2ECE0);
  box-shadow:
    8px 8px 18px rgba(180, 160, 130, 0.12),
    -8px -8px 18px rgba(255, 255, 255, 0.9),
    inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-a { background: var(--lavender); }
.dot-b { background: var(--rose); }
.dot-c { background: var(--sage); }

.brand-title {
  margin: 0 0 4px;
  font-size: 22px; font-weight: 600;
  letter-spacing: -0.02em;
}
.brand-sub {
  margin: 0;
  color: var(--ink-3);
  font-size: 13px;
  letter-spacing: 0.01em;
}

.form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  padding-left: 4px;
  letter-spacing: 0.02em;
}

.field input {
  height: 50px;
  padding: 0 18px;
  border-radius: var(--r-md);
  background: var(--cream-warm);
  box-shadow: var(--shadow-inset);
  font-size: 15px;
  color: var(--ink);
  transition: box-shadow .25s ease, background .25s ease;
}
.field input:focus {
  background: var(--paper);
  box-shadow:
    inset 1px 1px 2px rgba(0,0,0,0.03),
    inset -1px -1px 2px rgba(255,255,255,1),
    0 0 0 3px rgba(184, 164, 217, 0.18);
}

.btn {
  height: 50px;
  border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  transition: transform .15s ease, box-shadow .25s ease, background .25s ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(145deg, var(--lavender), var(--lavender-2));
  color: #fff;
  box-shadow:
    0 6px 16px rgba(155, 130, 196, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  margin-top: 4px;
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(155, 130, 196, 0.38), inset 0 1px 0 rgba(255,255,255,0.3); }
.btn-primary:disabled { opacity: 0.55; pointer-events: none; }

.btn-arrow { transition: transform .2s ease; }
.btn-primary:hover .btn-arrow { transform: translateX(2px); }

.btn-ghost {
  background: var(--cream-warm);
  color: var(--ink-2);
  height: 46px;
  border-radius: var(--r-md);
}

.btn-text {
  color: var(--lavender-2);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 999px;
}
.btn-text:hover { background: var(--lavender-soft); }

.error-text {
  margin: 4px 0 0;
  min-height: 18px;
  font-size: 13px;
  color: #C45C5C;
  text-align: center;
}

.login-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
}

/* ── Top bar ────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 4px 6px;
  margin-top: 8px;
  position: sticky; top: 0;
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream) 70%, transparent 100%);
  z-index: 5;
}

.topbar-chat {
  background: rgba(248, 244, 237, 0.85);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  padding: 12px 4px;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  margin: 0 -18px;
  padding-left: 18px;
  padding-right: 18px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 42px; height: 42px;
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  background: linear-gradient(145deg, #FFFFFF, var(--cream-warm));
  box-shadow:
    4px 4px 10px rgba(180,160,130,0.12),
    -4px -4px 10px rgba(255,255,255,0.85);
}

.topbar-text { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-hello { font-size: 12px; color: var(--ink-3); }
.topbar-name { font-size: 15px; font-weight: 600; color: var(--ink); }

.topbar-center { flex: 1; min-width: 0; padding: 0 14px; text-align: center; }
.topbar-title {
  font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-meta {
  font-size: 11px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--paper);
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  transition: transform .15s ease, box-shadow .2s ease;
}
.icon-btn:hover { box-shadow: var(--shadow-md); }
.icon-btn:active { transform: scale(0.94); }

/* ── Hero ──────────────────────────────────────────────── */

.hero {
  padding: 14px 4px 20px;
}
.hero-title {
  margin: 0 0 4px;
  font-size: 26px; font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--ink) 0%, var(--lavender-2) 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub { margin: 0; color: var(--ink-3); font-size: 14px; }

/* ── Search ─────────────────────────────────────────────── */

.search-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  margin-bottom: 14px;
  color: var(--ink-3);
}
.search-card input {
  flex: 1;
  font-size: 14px;
  color: var(--ink);
}
.search-card input::placeholder { color: var(--ink-4); }

/* ── Chip row ──────────────────────────────────────────── */

.chip-row {
  display: flex; gap: 8px;
  padding: 4px 2px 6px;
  margin: 0 -18px 6px;
  padding-left: 18px; padding-right: 18px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 500;
  color: var(--ink-2);
  box-shadow: var(--shadow-xs);
  transition: all .2s ease;
  white-space: nowrap;
}
.chip:active { transform: scale(0.96); }
.chip-active {
  background: var(--ink);
  color: var(--cream-soft);
  border-color: var(--ink);
  box-shadow: 0 4px 12px rgba(45, 42, 38, 0.18);
}

/* ── Section head ──────────────────────────────────────── */

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 4px 6px;
}
.section-head h3 {
  margin: 0; font-size: 12px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3);
}

/* ── Sessions list ─────────────────────────────────────── */

.sessions-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 100px; }

.session-card {
  background: var(--paper);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform .15s ease, box-shadow .25s ease;
  position: relative;
  overflow: hidden;
}
.session-card:active { transform: scale(0.985); box-shadow: var(--shadow-xs); }

.session-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--lavender) 0%, var(--rose) 100%);
  opacity: 0.5;
}

.session-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}

.session-title {
  font-size: 14.5px; font-weight: 600;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.005em;
  line-height: 1.45;
}

.session-time {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  margin-top: 2px;
}

.session-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.tag {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.01em;
}
.tag-project {
  background: var(--lavender-bg);
  color: var(--lavender-2);
}
.tag-count {
  background: var(--cream-warm);
  color: var(--ink-3);
}
.tag-role {
  background: rgba(181, 197, 176, 0.25);
  color: #6B8869;
}
.tag-role.user { background: rgba(224, 196, 190, 0.35); color: #A06A60; }
.tag-role.processing {
  background: rgba(184, 164, 217, 0.22);
  color: var(--lavender-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tag-role.processing::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lavender-2);
  animation: tag-pulse 1.4s infinite ease-in-out;
}
@keyframes tag-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.1);  }
}

/* ── Skeleton ──────────────────────────────────────────── */

.skeleton-card {
  height: 88px;
  border-radius: var(--r-lg);
  background:
    linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.5) 50%, transparent 100%),
    var(--cream-warm);
  background-size: 200% 100%, auto;
  animation: shimmer 1.6s infinite linear;
  border: 1px solid var(--line);
}
@keyframes shimmer {
  0% { background-position: -150% 0, 0 0; }
  100% { background-position: 150% 0, 0 0; }
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-3);
  font-size: 14px;
}

.history-hint {
  align-self: center;
  margin: 4px auto 12px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--ink-3);
  background: rgba(0, 0, 0, 0.035);
  border: 1px solid var(--line);
  border-radius: 999px;
  letter-spacing: .2px;
}

/* ── FAB ───────────────────────────────────────────────── */

.fab {
  position: fixed;
  right: max(20px, calc((100vw - 560px) / 2 + 20px));
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  width: 56px; height: 56px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--lavender), var(--lavender-2));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow:
    0 12px 28px rgba(155, 130, 196, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform .2s ease;
  z-index: 10;
}
.fab:active { transform: scale(0.92); }

/* ── Chat ──────────────────────────────────────────────── */

.view-chat {
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

.chat-messages {
  flex: 1 1 0;
  min-height: 0;
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 0 calc(env(safe-area-inset-bottom) + 110px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.msg-row { display: flex; gap: 10px; }
.msg-row.user { justify-content: flex-end; }
.msg-row.assistant { justify-content: flex-start; }

.msg-bubble {
  max-width: 86%;
  padding: 12px 16px;
  border-radius: var(--r-lg);
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: break-word;
  letter-spacing: -0.003em;
}

.msg-row.user .msg-bubble {
  background: linear-gradient(145deg, var(--lavender) 0%, var(--lavender-2) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(155, 130, 196, 0.28);
  border-bottom-right-radius: 8px;
}

.msg-row.assistant .msg-bubble {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  border-bottom-left-radius: 8px;
}

.msg-bubble code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--cream-warm);
  color: var(--ink);
  padding: 1px 6px;
  border-radius: 6px;
}
.msg-row.user .msg-bubble code {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.msg-bubble pre {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--cream-warm);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin: 8px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
}
.msg-row.user .msg-bubble pre {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.16);
  color: #fff;
}

.tool-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--lavender-bg);
  color: var(--lavender-2);
  font-family: var(--mono);
  margin: 4px 4px 0 0;
}
.tool-chip.error { background: rgba(196,92,92,0.10); color: #B84A4A; }

/* Tool-only bubbles → strip the bubble shell so the chips float */
.msg-bubble.tools-only {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 4px;
}

.typing {
  display: inline-flex; gap: 4px; padding: 4px 0;
}
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-4);
  animation: typing 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── Composer ──────────────────────────────────────────── */

.composer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 10px 18px calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(180deg, transparent 0%, var(--cream) 35%);
  z-index: 20;
}

.composer-pill {
  max-width: 524px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  background: var(--paper);
  border-radius: 26px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  transition: box-shadow .25s ease;
}
.composer-pill:focus-within { box-shadow: var(--shadow-lg); }

.composer-tool {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--cream-warm);
  color: var(--ink-2);
  font-size: 12px; font-weight: 500;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.composer-pill textarea {
  flex: 1;
  resize: none;
  font-size: 15px;
  line-height: 1.45;
  padding: 8px 4px;
  max-height: 140px;
  min-height: 24px;
  color: var(--ink);
}
.composer-pill textarea::placeholder { color: var(--ink-4); }

.composer-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--lavender), var(--lavender-2));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(155, 130, 196, 0.32);
  flex-shrink: 0;
  transition: transform .15s ease, opacity .2s ease;
}
.composer-send:active { transform: scale(0.92); }
.composer-send:disabled { opacity: 0.45; pointer-events: none; }

/* ── Sheet ──────────────────────────────────────────────── */

.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(45, 42, 38, 0.32);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-width: 560px;
  padding: 8px 22px calc(env(safe-area-inset-bottom) + 22px);
  background: var(--cream-soft);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: 0 -10px 40px rgba(45, 42, 38, 0.16);
  animation: slideUp .3s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-handle {
  width: 40px; height: 4px;
  background: var(--ink-4);
  border-radius: 2px;
  margin: 6px auto 14px;
  opacity: 0.4;
}

.sheet-title {
  margin: 0 0 14px;
  font-size: 16px; font-weight: 600;
  text-align: center;
}

.sheet-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

/* Directory picker — breadcrumb + scrollable listing + actions */
#dir-sheet .sheet { max-height: 86dvh; display: flex; flex-direction: column; }

.dir-crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--cream-warm);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  min-height: 20px;
}
.crumb {
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--lavender-2);
  font-weight: 500;
  font-family: var(--mono);
}
.crumb:hover { background: var(--lavender-bg); }
.crumb.crumb-current {
  color: var(--ink);
  font-weight: 600;
  pointer-events: none;
}
.crumb-sep { color: var(--ink-4); padding: 0 1px; user-select: none; }

.dir-listing {
  flex: 1 1 auto; min-height: 0;
  max-height: 52dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
}

.dir-entry {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s ease;
}
.dir-entry:hover { background: var(--lavender-bg); }
.dir-entry:active { transform: scale(0.99); }
.dir-entry.up { color: var(--ink-3); font-style: italic; }

.dir-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  color: var(--lavender-2);
  flex-shrink: 0;
}
.dir-entry-name {
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dir-entry-go {
  color: var(--ink-4);
  flex-shrink: 0;
  font-size: 13px;
}

.dir-empty {
  padding: 22px 12px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

.dir-actions {
  display: flex; gap: 10px; margin-top: 4px;
}
.dir-actions #dir-cancel { flex: 0 0 auto; padding: 0 18px; }
.dir-actions #dir-confirm { flex: 1; }

.btn-compact {
  height: 46px;
  padding: 0 18px;
  font-size: 14px;
  margin-top: 0;
  flex-shrink: 0;
}

.sheet-option {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 14.5px;
  cursor: pointer;
  transition: background .2s ease;
}
.sheet-option:hover { background: var(--lavender-bg); }
.sheet-option.active {
  background: var(--lavender-bg);
  border-color: var(--lavender);
  color: var(--lavender-2);
  font-weight: 600;
}
.sheet-option .check {
  width: 18px; height: 18px; opacity: 0;
}
.sheet-option.active .check { opacity: 1; }

.sheet-content {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 14px;
}
.kv {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 14px;
  background: var(--paper);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  font-size: 13px;
}
.kv-key { color: var(--ink-3); flex-shrink: 0; }
.kv-val { color: var(--ink); font-family: var(--mono); font-size: 12px; word-break: break-all; text-align: right; }

/* ── Toast ─────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 100px);
  background: var(--ink);
  color: var(--cream-soft);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: toastIn .3s ease;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ── Misc ──────────────────────────────────────────────── */

::selection { background: var(--lavender-soft); color: var(--ink); }

@media (min-width: 720px) {
  .view { padding-left: 24px; padding-right: 24px; }
}

/* ── Welcome state (no chat selected) ──────────────────── */
.chat-welcome {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.welcome-card {
  text-align: center;
  max-width: 360px;
  padding: 36px 32px;
  border-radius: var(--r-xl);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.welcome-mark {
  display: inline-flex; gap: 6px; margin-bottom: 14px;
  width: 56px; height: 56px;
  border-radius: 16px;
  align-items: center; justify-content: center;
  background: linear-gradient(145deg, #FFFFFF, var(--cream-warm));
  box-shadow: 6px 6px 14px rgba(180,160,130,0.12), -6px -6px 14px rgba(255,255,255,0.85);
}
.welcome-title {
  margin: 0 0 6px;
  font-size: 20px; font-weight: 600;
  letter-spacing: -0.015em;
  background: linear-gradient(135deg, var(--ink) 0%, var(--lavender-2) 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.welcome-sub { margin: 0; color: var(--ink-3); font-size: 14px; line-height: 1.6; }

/* ── Desktop layout ≥1024px ────────────────────────────── */
@media (min-width: 1024px) {
  body.app {
    display: grid;
    grid-template-columns: 380px 1fr;
    grid-template-rows: 100dvh;
    gap: 0;
    max-width: 1400px;
    margin: 0 auto;
    overflow: hidden;
  }

  /* Both panes always visible inside .app — override .hidden but only for these */
  body.app #view-list,
  body.app #view-chat {
    display: flex !important;
    max-width: none;
    margin: 0;
    height: 100dvh;
    min-height: 0;
    padding: 18px 22px;
  }

  body.app #view-list {
    flex-direction: column;
    border-right: 1px solid var(--line);
    background:
      linear-gradient(180deg, rgba(255,255,255,0.4), rgba(255,255,255,0.1)),
      var(--cream);
    overflow: hidden;
  }
  body.app #view-list .topbar { background: transparent; }
  body.app #view-list .hero { padding: 8px 4px 14px; }
  body.app #view-list .hero-title { font-size: 22px; }
  body.app #view-list .hero-sub { display: none; }

  body.app #sessions-list {
    flex: 1; min-height: 0;
    overflow-y: auto;
    padding-bottom: 80px;
    -webkit-overflow-scrolling: touch;
  }

  /* FAB — make it sidebar-local */
  body.app .fab {
    right: auto;
    left: 22px;
    bottom: 22px;
    position: absolute;
  }
  body.app #view-list { position: relative; }

  body.app #view-chat {
    flex-direction: column;
    padding: 0;
    height: 100dvh;
  }
  body.app #view-chat .topbar-chat {
    margin: 0;
    padding: 14px 28px;
    border-radius: 0;
    border-bottom: 1px solid var(--line);
  }
  body.app #view-chat .chat-messages {
    padding: 28px 28px calc(env(safe-area-inset-bottom) + 110px);
    align-items: stretch;
  }
  body.app #view-chat .chat-messages > .msg-row {
    max-width: 880px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }
  body.app #view-chat .composer {
    background: linear-gradient(180deg, transparent 0%, var(--cream) 35%);
    padding: 14px 28px calc(env(safe-area-inset-bottom) + 18px);
  }
  body.app #view-chat .composer-pill {
    max-width: 880px;
  }

  /* Hide back button on desktop — list is always visible */
  body.app #view-chat #back-btn { display: none; }

  /* Active session highlight */
  body.app .session-card.active {
    background: var(--lavender-bg);
    border-color: var(--lavender);
    box-shadow: 0 4px 14px rgba(155, 130, 196, 0.16);
  }
  body.app .session-card.active::before { opacity: 1; width: 4px; }

  /* Welcome state */
  body.app #chat-welcome { padding-top: 60px; }

  /* Login stays the same on desktop — single centered card */
  body.app #view-login { display: none !important; }
}

/* ── Markdown rendering (chat bubbles) ─────────────────── */

.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 8px 0; padding-left: 22px; }
.msg-bubble li { margin: 2px 0; }
.msg-bubble strong { font-weight: 600; }
.msg-bubble a { color: var(--lavender-2); text-decoration: underline; text-underline-offset: 2px; }
.msg-row.user .msg-bubble a { color: rgba(255,255,255,0.9); }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 { margin: 10px 0 6px; font-weight: 600; }
.msg-bubble h1 { font-size: 17px; }
.msg-bubble h2 { font-size: 16px; }
.msg-bubble h3 { font-size: 15px; }
