/* ============================================================
   Beany design tokens — light is the base, data-theme="dark"
   overrides. data-accent="pink|blue|violet|mint" swaps accent only.
   Workspace IDE semantics (--panel, --user, --tool, --ok, --error)
   are kept as legacy aliases that follow the active theme.
   ============================================================ */
:root {
  /* Brand palette */
  --pink: #FF5C93;
  --pink-2: #FF7AA8;
  --pink-soft: #FFE6EE;
  --pink-softer: #FFF1F6;

  --navy: #0B1F3A;
  --navy-2: #0E2647;
  --sky: #3B82F6;
  --deep-blue: #1E3A8A;

  /* Active accent — pink default */
  --accent: var(--pink);
  --accent-2: var(--pink-2);
  --accent-soft: var(--pink-soft);
  --accent-softer: var(--pink-softer);
  --accent-tint: rgba(255, 92, 147, 0.14);
  --accent-glow: rgba(255, 92, 147, 0.28);
  --accent-strong: #FF4080;

  /* Surfaces — light theme defaults */
  --bg: #FFFFFF;
  --bg-soft: #F7F8FA;
  --bg-muted: #F0F2F6;
  --surface: #FFFFFF;
  --surface-2: #FBFBFD;
  --border: #E5E8EE;
  --border-strong: #D6DAE2;

  --text-strong: #0B1F3A;
  --text: #14181F;
  --text-muted: #6B7280;
  --text-faint: #A7AEBB;

  --shadow-card: 0 1px 2px rgba(11,31,58,0.04), 0 8px 24px rgba(11,31,58,0.06);
  --shadow-lift: 0 2px 4px rgba(11,31,58,0.04), 0 24px 48px rgba(11,31,58,0.10);

  /* Hero gradient (landing) */
  --hero-bg: linear-gradient(180deg, #0E2647 0%, #0B1F3A 100%);
  --hero-text: #FFFFFF;
  --hero-text-muted: rgba(255,255,255,0.78);

  /* Radii */
  --radius-pill: 999px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-card: 22px;     /* legacy: large card */
  --radius-section: 36px;  /* legacy: hero sections */

  /* Spacing (4px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Elevation surfaces (semantic aliases) */
  --bg-elev: var(--surface);
  --bg-elev-2: var(--surface-2);
  --surface-hover: #eef2f8;

  /* Semantic colors */
  --danger: #c0392b;
  --success: #2ecc71;
  --warning: #f39c12;

  /* Motion */
  --ease-out: cubic-bezier(.2,.8,.2,1);
  --ease-in-out: cubic-bezier(.4,0,.2,1);
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;

  /* Shadows (numbered scale) */
  --shadow-1: 0 1px 3px rgba(20,30,50,.06);
  --shadow-2: 0 4px 12px rgba(20,30,50,.08);
  --shadow-3: 0 8px 24px rgba(20,30,50,.12);

  /* Topbar specific */
  --topbar-height: 56px;

  /* Legacy IDE semantics — alias to active theme tokens */
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --muted: var(--text-muted);
  --user: var(--accent-softer);
  --tool: #eaf3ec;
  --error: #d94545;
  --ok: #1f9d55;
}

/* Accent palettes — pink is default in :root, others opt-in via data-accent. */
html[data-accent="pink"] {
  /* no-op: matches :root default */
}
html[data-accent="blue"] {
  --accent: var(--sky);
  --accent-2: #60A5FA;
  --accent-soft: #DCEBFF;
  --accent-softer: #EAF2FF;
  --accent-tint: rgba(59,130,246,0.14);
  --accent-glow: rgba(59,130,246,0.30);
  --accent-strong: #4A8AFF;
}
html[data-accent="violet"] {
  --accent: #7A5AE0;
  --accent-2: #9B83F0;
  --accent-soft: #E6DEFA;
  --accent-softer: #F1ECFD;
  --accent-tint: rgba(122,90,224,0.14);
  --accent-glow: rgba(122,90,224,0.30);
}
html[data-accent="mint"] {
  --accent: #10B981;
  --accent-2: #34D9A4;
  --accent-soft: #D1FAE9;
  --accent-softer: #E8FBF2;
  --accent-tint: rgba(16,185,129,0.14);
  --accent-glow: rgba(16,185,129,0.30);
}

/* Dark theme — matches the original IDE palette (pre-Beany) for workspace surfaces */
html[data-theme="dark"] {
  --bg: #0e0f12;
  --bg-soft: #14161b;
  --bg-muted: #1d2026;
  --surface: #16181d;
  --surface-2: #1d2026;
  --border: #262a31;
  --border-strong: #353a45;

  --text-strong: #f4f7fb;
  --text: #e6e8ec;
  --text-muted: #8a8f99;
  --text-faint: #6a7282;

  --shadow-card: 0 1px 2px rgba(0,0,0,0.30), 0 8px 24px rgba(0,0,0,0.30);
  --shadow-lift: 0 2px 4px rgba(0,0,0,0.30), 0 24px 48px rgba(0,0,0,0.40);

  --hero-bg: radial-gradient(900px 540px at 20% -10%, rgba(59,130,246,0.18), transparent 60%),
             radial-gradient(700px 420px at 110% 110%, rgba(255,92,147,0.16), transparent 60%),
             linear-gradient(180deg, #0A1424 0%, #060E1C 100%);
  --hero-text: #FFFFFF;
  --hero-text-muted: rgba(255,255,255,0.74);

  /* IDE semantics in dark */
  --user: rgba(255, 92, 147, 0.16);
  --tool: #1f2a22;
  --error: #ff6b6b;
  --ok: #6bcf7f;

  /* Accent soft tokens become transparent overlays in dark mode. The light
     theme uses near-white tints which look washed out against dark surfaces.
     rgba lets the dark surface show through so the tint stays subtle
     regardless of accent palette. Default is pink. */
  --accent-soft:   rgba(255, 92, 147, 0.22);
  --accent-softer: rgba(255, 92, 147, 0.10);
  --accent-strong: #FF7AA8;

  /* Semantic surface aliases — dark variants */
  --bg-elev: var(--surface);
  --bg-elev-2: var(--surface-2);
  --surface-hover: #262a31;

  /* Shadow alpha bumped slightly for dark surfaces */
  --shadow-1: 0 1px 3px rgba(0,0,0,.30);
  --shadow-2: 0 4px 12px rgba(0,0,0,.36);
  --shadow-3: 0 8px 24px rgba(0,0,0,.40);
}
html[data-theme="dark"][data-accent="pink"] {
  /* no-op: matches dark default (pink) */
}
html[data-theme="dark"][data-accent="blue"] {
  --accent-soft:   rgba(59, 130, 246, 0.22);
  --accent-softer: rgba(59, 130, 246, 0.10);
  --accent-strong: #6FA3FF;
}
html[data-theme="dark"][data-accent="violet"] {
  --accent-soft:   rgba(122, 90, 224, 0.22);
  --accent-softer: rgba(122, 90, 224, 0.10);
}
html[data-theme="dark"][data-accent="mint"] {
  --accent-soft:   rgba(16, 185, 129, 0.22);
  --accent-softer: rgba(16, 185, 129, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", sans-serif;
  font-size: 14px;
  overflow: hidden;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}
button:hover { background: #252932; }
button.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.primary:hover { background: var(--accent-2); }
button.cancel { background: #4a2828; border-color: #6a3434; color: #ffd0d0; }
button.cancel:hover { background: #5a3030; }
.hidden { display: none !important; }
.cursor {
  display: inline-block;
  width: 8px; height: 16px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: blink 0.8s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Rich "thinking" placeholder shown while the LLM hasn't sent a token yet,
 * or between tool calls. Includes label, elapsed timer, and time-gated hint. */
.msg.thinking {
  align-self: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 10px;
  width: fit-content;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.thinking-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}
.thinking-icon {
  font-size: 14px;
  color: var(--accent);
  animation: thinking-pulse 1.4s ease-in-out infinite;
  display: inline-block;
}
.thinking-label { font-weight: 500; }
.thinking-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.thinking-elapsed { font-weight: 600; }
.thinking-hint { font-style: italic; opacity: 0.85; }
@keyframes thinking-pulse {
  0%, 100% { opacity: 0.5; transform: rotate(0deg) scale(1); }
  50%      { opacity: 1;   transform: rotate(180deg) scale(1.15); }
}

.dots { display: inline-flex; gap: 5px; align-items: center; }
.dots span {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: dot-bounce 1.3s infinite ease-in-out both;
}
.dots span:nth-child(1) { animation-delay: -0.32s; }
.dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.3); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

input, select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  width: 100%;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

/* Top bar */
.topbar {
  position: relative; /* anchor for #loading-bar */
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  gap: 16px;
}

/* Global loading bar — sits at the very bottom edge of the topbar.
 * Active whenever any API call is in flight.                        */
#loading-bar {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%;
  height: 2px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
  background: transparent;
}
#loading-bar.active {
  opacity: 1;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent) 25%,
    #5bffcf 50%,
    var(--accent) 75%,
    transparent 100%
  );
  background-size: 300% 100%;
  animation: lb-shimmer 1.3s ease-in-out infinite;
}
@keyframes lb-shimmer {
  0%   { background-position:  100% 0; }
  100% { background-position: -100% 0; }
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand-mark { color: var(--accent); }
.spacer { flex: 1; }

/* Workspace topbar elements */
.back-link {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.back-link:hover { background: var(--panel-2); color: var(--text); }
.app-title { display: flex; align-items: center; min-width: 0; }
.app-name {
  font-weight: 600;
  font-size: 15px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: text;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 360px;
}
.app-name:hover { background: var(--panel-2); }
.app-name-input {
  font-weight: 600;
  font-size: 15px;
  padding: 3px 8px;
  width: 280px;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 380px 240px 1fr;
  height: calc(100vh - 48px);
}
/* Files pane is hidden by default; toggle via #files-toggle button. */
body.files-hidden .layout { grid-template-columns: 380px 1fr; }
body.files-hidden .files-pane { display: none; }
#files-toggle.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
#files-toggle { position: relative; }
#files-toggle.has-new::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--ok);
  border-radius: 50%;
  border: 1.5px solid var(--panel);
}

/* Pane tabs (used in chat-pane and files-pane) */
.pane-tabs {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  height: 36px;
}
.pane-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
}
.pane-tab:hover { background: var(--panel-2); color: var(--text); }
.pane-tab.active { background: var(--panel-2); color: var(--text); border-color: var(--border); }
.tab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  margin-left: 4px;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
}

/* Chat */
.chat {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--panel);
  min-width: 0;
  min-height: 0; /* allow grid child to shrink so .messages can scroll */
  height: 100%;
}
.chat-body, .notes-body {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.messages {
  flex: 1 1 0;
  min-height: 0; /* unlock overflow inside the flex column */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
.msg.user { background: var(--user); border-color: #344056; align-self: flex-end; max-width: 90%; }
.msg.assistant { background: var(--panel-2); }
.msg.tool {
  background: var(--tool);
  border-color: #2a3a30;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #c8d9c8;
}
.msg.error {
  background: #2a1a1a;
  border-color: #4a2a2a;
  color: var(--error);
}
.msg .role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}
.msg.tool .tool-name { color: var(--ok); font-weight: 600; }

/* Chat composer — lifted card so it reads as an input region, not background.
   The textarea has its own visible border + focus ring, and the send button
   is a filled primary so it never disappears into the surrounding chrome. */
.composer {
  border-top: 1px solid var(--border);
  padding: 12px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
  /* Never let the flex algorithm shrink the composer so the Send button
     stays visible on small screens / when the keyboard is up. Messages
     area (flex:1) gives up space first. */
  flex: 0 0 auto;
  /* iPhone home indicator. Safe to set globally; non-iOS resolves to 0. */
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.composer textarea {
  resize: none;
  min-height: 64px;
  max-height: 200px;
  padding: 12px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  font: inherit;
  line-height: 1.5;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.composer .hint { color: var(--muted); font-size: 12px; }
#send-btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 9px 18px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(255,92,147,0.25), 0 4px 12px rgba(255,92,147,0.18);
  transition: background .15s, transform .05s, box-shadow .15s;
}
#send-btn:hover:not(:disabled) {
  background: var(--accent-strong);
  box-shadow: 0 2px 4px rgba(255,92,147,0.30), 0 8px 18px rgba(255,92,147,0.22);
}
#send-btn:active:not(:disabled) { transform: translateY(1px); }
#send-btn:disabled {
  background: var(--bg-muted);
  color: var(--text-faint);
  box-shadow: none;
  cursor: not-allowed;
}
#cancel-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
#cancel-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* AI mode chip (above the textarea). Lightweight pill that opens a
   menu of modes from /api/ai-modes. Persisted per app. */
.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  position: relative;
}
.ai-mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.ai-mode-chip:hover { color: var(--text); border-color: var(--accent); }
.ai-mode-chip[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-softer);
}
.ai-mode-chip .ai-mode-icon { font-size: 13px; line-height: 1; }
.ai-mode-chip .ai-mode-label { font-weight: 600; color: var(--text); }
.ai-mode-chip:hover .ai-mode-label { color: var(--text); }
.ai-mode-chip[aria-expanded="true"] .ai-mode-label { color: var(--accent); }
.ai-mode-chip .ai-mode-caret { font-size: 10px; opacity: 0.7; }

.ai-mode-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lift);
  padding: 6px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ai-mode-menu.hidden { display: none; }
.ai-mode-menu .ai-mode-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  grid-template-rows: auto auto;
  gap: 2px 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  color: var(--text);
}
.ai-mode-menu .ai-mode-item:hover { background: var(--accent-softer); }
.ai-mode-menu .ai-mode-item.active { background: var(--accent-soft); }
.ai-mode-menu .ai-mode-item .mi-icon { grid-row: 1 / span 2; font-size: 16px; align-self: center; }
.ai-mode-menu .ai-mode-item .mi-label { font-weight: 600; font-size: 13px; color: var(--text-strong); }
.ai-mode-menu .ai-mode-item.active .mi-label { color: var(--accent); }
.ai-mode-menu .ai-mode-item .mi-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

/* Conflict resolution modal (Phase 11 follow-on, 412 UI) */
.conflict-modal { position:fixed; inset:0; background:rgba(20,28,46,.55); display:flex; align-items:center; justify-content:center; z-index:9999; padding:16px; }
.conflict-modal.hidden { display:none; }
.conflict-modal-card {
  background:white; color:#2a3140; border-radius:12px; width:100%; max-width:1100px;
  max-height:90vh; display:flex; flex-direction:column;
  box-shadow:0 16px 48px rgba(20,30,50,.30);
  font-family:-apple-system,"Pretendard","Apple SD Gothic Neo",sans-serif;
}
.conflict-modal-head {
  display:flex; align-items:flex-start; justify-content:space-between; gap:12px;
  padding:18px 22px; border-bottom:1px solid #e3e8f0;
}
.conflict-modal-title { font-weight:600; font-size:15px; }
.conflict-modal-sub { font-size:12px; margin-top:2px; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }
.conflict-close { background:transparent; border:none; font-size:18px; cursor:pointer; color:#5b6577; }
.conflict-close:hover { color:#2a3140; }
.conflict-body { flex:1; display:grid; grid-template-columns:1fr 1fr; gap:0; min-height:0; }
.conflict-col { display:flex; flex-direction:column; min-width:0; border-right:1px solid #e3e8f0; }
.conflict-col:last-child { border-right:none; }
.conflict-col-head { padding:8px 14px; background:#f7f9fc; border-bottom:1px solid #e3e8f0; font-size:12px; font-weight:600; color:#5b6577; }
.conflict-pane {
  margin:0; padding:0; overflow:auto; flex:1; min-height:240px; max-height:60vh;
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:12px; line-height:1.55;
  background:white;
}
.conflict-pane .line { display:block; padding:1px 12px; white-space:pre; }
.conflict-pane .line.add { background:#e6f7ec; }
.conflict-pane .line.del { background:#fbeae6; }
.conflict-pane .line.gap { background:#f3f6fb; color:#8892a3; text-align:center; padding:4px 12px; }
.conflict-modal-foot { display:flex; justify-content:flex-end; gap:8px; padding:14px 22px; border-top:1px solid #e3e8f0; }
.conflict-modal-foot button { padding:9px 14px; border:1px solid #d2dae6; border-radius:8px; background:white; cursor:pointer; font-size:13px; }
.conflict-modal-foot button:hover { background:#f3f6fb; }
.conflict-modal-foot button.primary { background:#5b9cff; color:white; border-color:#5b9cff; }
.conflict-modal-foot button.primary:hover { background:#4a8aff; }

/* Credit wall (Phase 11 Step 1) — shown in place of the composer when balance ≤ 0 */
.credit-wall {
  border-top: 1px solid var(--border);
  padding: 16px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.credit-wall.hidden { display: none; }
.credit-wall-title { font-weight: 600; font-size: 14px; }
.credit-wall-body { color: var(--muted); font-size: 13px; line-height: 1.5; }
.credit-wall-actions { display: flex; flex-direction: column; gap: 6px; }
.credit-wall-actions button { padding: 9px 12px; text-align: left; }
.credit-wall-actions button.primary { background: var(--accent, #0066cc); color: white; }
.credit-wall-foot { color: var(--muted); font-size: 11px; }

/* Files pane */
.files-pane {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  min-height: 0;
  overflow: hidden;
}
.files-pane .pane-tabs .icon-btn {
  position: static;
  width: 24px;
  height: 24px;
  font-size: 12px;
  background: transparent;
  border-color: transparent;
}
.files-pane .pane-tabs .icon-btn:hover { background: var(--panel-2); border-color: var(--border); }

.files-body, .history-body, .console-body {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Preview console (errors / warnings forwarded from preview iframe) */
.console-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.console-list .empty {
  color: var(--muted); font-size: 12px; font-style: italic;
  text-align: center; padding: 30px 12px;
}
.console-item {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  cursor: default;
  position: relative;
}
.console-item:hover { border-color: var(--accent); }
.console-item.error,
.console-item.console-error,
.console-item.rejection { border-left-color: var(--error); }
.console-item.console-warn { border-left-color: #d4a955; }
.console-item .ci-row1 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.console-item .ci-kind {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
  flex: none;
}
.console-item .ci-time {
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.console-item .ci-loc {
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}
.console-item .ci-msg {
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.45;
}
.console-item .ci-stack {
  margin-top: 4px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  white-space: pre-wrap;
  max-height: 80px;
  overflow: auto;
}
.console-item .ci-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.console-item:hover .ci-actions { opacity: 1; }
.console-item .ci-actions button {
  padding: 2px 6px;
  font-size: 11px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.console-item .ci-actions .send-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--panel); }
.console-item .ci-actions .del-btn:hover  { color: var(--error); }
.console-item .ci-count {
  font-size: 10px;
  color: var(--muted);
  background: var(--panel);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: auto;
}

#files-toggle.has-console-error::before {
  content: '⚠';
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 9px;
  color: var(--error);
}

.file-tree {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 4px 14px;
  font-size: 13px;
}
.file-tree .empty {
  padding: 14px 12px;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}
.tree-node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}
.tree-node:hover { background: var(--panel-2); }
.tree-node.active {
  background: rgba(91, 156, 255, 0.18);
  color: var(--accent);
}
.tree-node .twisty {
  width: 12px;
  display: inline-block;
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  flex: none;
}
.tree-node .icon {
  flex: none;
  font-size: 12px;
  color: var(--muted);
}
.tree-node.dir > .icon { color: #d3b873; }

/* Drag-and-drop upload feedback (Files pane). */
.files-body.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  background: var(--accent-softer);
}
.files-body.drag-over .file-tree::after {
  content: '드롭하면 업로드 (폴더 위로 드롭하면 그 폴더로)';
  display: block;
  text-align: center;
  padding: 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  border-top: 1px dashed var(--accent);
  margin-top: 8px;
}
.tree-node.dir.drop-target {
  background: var(--accent-soft);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  border-radius: 4px;
}
.tree-node .label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-children {
  display: flex;
  flex-direction: column;
}
.tree-children.collapsed { display: none; }

/* Preview */
.preview {
  position: relative;
  display: flex;
  flex-direction: column;
  background: white;
  min-width: 0;
}
.preview-toolbar {
  height: 36px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 10px;
}
.preview-tabs { display: flex; gap: 4px; align-items: center; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { background: var(--panel-2); color: var(--text); }
.tab.active { background: var(--panel-2); color: var(--text); border-color: var(--border); }
.tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
}
.tab-close:hover { background: var(--panel-2); color: var(--text); }
.preview-url { color: var(--muted); font-family: ui-monospace, monospace; font-size: 12px; }
#preview-frame {
  flex: 1;
  border: none;
  width: 100%;
  background: white;
}

/* Visual editor (GrapesJS) — overlay layout inside the preview pane.
 * Canvas + property panel are split horizontally; toolbar sits on top. */
.visual-editor {
  position: absolute;
  top: 36px; /* below preview-toolbar */
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.visual-toolbar {
  flex: none;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.visual-toolbar button { padding: 4px 10px; font-size: 12px; }
.visual-body {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 320px;
}
.visual-canvas {
  position: relative;
  background: white;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}
.props-pane {
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.props-tabs {
  flex: none;
  display: flex;
  gap: 2px;
  padding: 6px 6px 0;
  border-bottom: 1px solid var(--border);
}
.props-tab {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 5px 5px 0 0;
  font-size: 12px;
}
.props-tab:hover { background: var(--panel-2); color: var(--text); }
.props-tab.active { background: var(--panel-2); color: var(--text); border-color: var(--border); }
.props-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}

/* Hide GrapesJS's own panel chrome — we project its managers into our tabs.
 * Only the canvas itself stays visible inside #visual-canvas. */
.visual-canvas .gjs-pn-panels,
.visual-canvas .gjs-pn-views,
.visual-canvas .gjs-pn-views-container,
.props-pane .gjs-pn-panels { display: none; }
.props-body .gjs-sm-sectors,
.props-body .gjs-trt-traits,
.props-body .gjs-clm-tags,
.props-body .gjs-layer { color: var(--text); }
.props-body .gjs-mdl-dialog { color: var(--text); }
/* Soften GrapesJS dark theme to match ours where it leaks through. */
.props-pane .gjs-one-bg { background-color: var(--panel) !important; }
.props-pane .gjs-two-color { color: var(--text) !important; }
.props-pane .gjs-three-bg { background-color: var(--panel-2) !important; }
.props-pane .gjs-four-color, .props-pane .gjs-four-color-h:hover { color: var(--accent) !important; }

/* When Visual mode is active, hide the iframe and code viewer overlays. */
body.visual-mode .preview-frame,
body.visual-mode #preview-frame { display: none; }

@media (max-width: 1100px) {
  .visual-body { grid-template-columns: 1fr 280px; }
}

/* Code viewer overlay (sits above the iframe in the preview area) */
.code-viewer {
  position: absolute;
  top: 36px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.code-toolbar {
  flex: none;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.code-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 50%;
}
.code-status { font-size: 12px; color: var(--muted); }
.code-toolbar button { padding: 4px 10px; font-size: 12px; }
.code-viewer pre {
  flex: 1;
  margin: 0;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre;
  tab-size: 2;
  overflow: auto;
}

/* Media preview (image/video/audio) — replaces the <pre> for binary media. */
.media-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  overflow: auto;
  /* Checkered transparency background so PNGs with alpha read clearly. */
  background-color: var(--panel-2);
  background-image:
    linear-gradient(45deg, rgba(127,127,127,0.12) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(127,127,127,0.12) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(127,127,127,0.12) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(127,127,127,0.12) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.media-preview .media-image {
  max-width: 100%;
  max-height: calc(100vh - 200px);
  object-fit: contain;
  border-radius: 6px;
  box-shadow: var(--shadow-2);
}
.media-preview .media-video {
  max-width: 100%;
  max-height: calc(100vh - 200px);
  background: #000;
  border-radius: 6px;
}
.media-preview .media-audio { width: min(480px, 100%); }
.media-preview .media-meta {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#code-editor {
  flex: 1;
  width: 100%;
  margin: 0;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  border: none;
  border-radius: 0;
  resize: none;
  outline: none;
  white-space: pre;
  tab-size: 2;
}
#code-editor:focus { border: none; }

/* Settings modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: 520px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal h2 { margin: 0 0 4px; }
.modal label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}
.muted { color: var(--muted); font-weight: normal; font-size: 12px; }
.muted code { background: #2a2f38; padding: 1px 5px; border-radius: 3px; color: #cfd6e0; }

/* ============================================================
 * App list page
 * ============================================================ */

.page-list { overflow: auto; }
.page-list .topbar { position: sticky; top: 0; z-index: 10; }

.list-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

/* /me view switcher (Apps / Settings). One row of pill-style tabs. */
.me-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.me-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--dur-fast, .12s) var(--ease-out, ease),
              border-color var(--dur-fast, .12s) var(--ease-out, ease);
}
.me-tab:hover { color: var(--text); }
.me-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.view.hidden { display: none; }

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.list-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}
.list-header .count {
  color: var(--muted);
  font-weight: normal;
  font-size: 16px;
  margin-left: 6px;
}

button.big {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
}

.empty-state {
  margin: 60px auto;
  max-width: 460px;
  text-align: center;
  padding: 40px 24px;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.empty-state h2 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
.empty-state p { color: var(--muted); margin: 0 0 20px; }

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

/* Card */
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Thumbnail iframe — shrink a desktop-sized iframe into the card. */
.card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: white;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.card-thumb iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1280px;
  height: 800px;
  border: none;
  transform: scale(0.25);
  transform-origin: top left;
  pointer-events: none;
}

.card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.card-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.card-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.card-meta { font-size: 12px; color: var(--muted); }
.card-snippet {
  font-size: 12px;
  color: #a8b0bd;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: 4px;
  font-style: italic;
}

/* Action icons (rename / delete) */
.card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.card:hover .card-actions,
.card:focus-within .card-actions { opacity: 1; }

.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
html[data-theme="dark"] .icon-btn { background: rgba(20, 22, 28, 0.85); color: var(--text); }
.icon-btn:hover { background: var(--accent-softer); color: var(--accent); border-color: var(--accent); }
html[data-theme="dark"] .icon-btn:hover { background: var(--panel-2); color: var(--accent); border-color: var(--accent); }

/* Credit chip — topbar quick-glance balance. Shared between /me and workspace. */
.credit-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; margin-right: 4px;
  background: var(--accent-softer); color: var(--accent);
  border: 1px solid var(--accent-soft);
  border-radius: 999px; font-size: 13px; font-weight: 600;
  text-decoration: none; cursor: pointer; line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: background .15s, border-color .15s, color .15s;
}
.credit-chip:hover { background: var(--accent-soft); border-color: var(--accent); }
.credit-chip.low { color: #c44; background: rgba(204,68,68,0.10); border-color: rgba(204,68,68,0.25); }
.credit-chip.low:hover { background: rgba(204,68,68,0.18); }

/* Notes panel */
.notes-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.notes-list .empty {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  text-align: center;
  padding: 30px 12px;
}
.note-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 13px;
  line-height: 1.45;
}
.note-item.done { opacity: 0.55; }
.note-item.done .note-text { text-decoration: line-through; }
.note-item input[type="checkbox"] {
  flex: none;
  width: 14px;
  height: 14px;
  margin-top: 3px;
  cursor: pointer;
}
.note-item .note-text {
  flex: 1 1 0;
  word-break: break-word;
  cursor: text;
}
.note-item .note-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.note-item:hover .note-actions { opacity: 1; }
.note-item .note-actions button {
  padding: 2px 6px;
  font-size: 11px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.note-item .note-actions button:hover { background: var(--panel); color: var(--text); }
.note-item .note-actions .send-btn:hover { color: var(--accent); }
.note-item .note-actions .delete-btn:hover { color: var(--error); }

/* Sessions panel */
.sessions-body {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.sessions-toolbar {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.sessions-toolbar button { flex: 1; padding: 7px 0; font-size: 13px; }
.sessions-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sessions-list .empty {
  color: var(--muted); font-size: 12px; font-style: italic;
  text-align: center; padding: 24px 12px;
}
.session-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  cursor: default;
}
.session-item:hover { border-color: var(--accent); }
.session-item .body { flex: 1 1 0; min-width: 0; }
.session-item .label {
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-item .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.session-item .actions {
  display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s;
}
.session-item:hover .actions { opacity: 1; }
.session-item .actions button {
  padding: 3px 8px; font-size: 11px;
  background: transparent; border-color: transparent; color: var(--muted);
}
.session-item .actions .load-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--panel); }
.session-item .actions .del-btn:hover { color: var(--error); }

.note-composer {
  flex: none;
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.note-composer input { flex: 1 1 0; padding: 6px 10px; font-size: 13px; }
.note-composer button {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}

/* History panel */
.history-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-list .empty {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  text-align: center;
  padding: 30px 12px;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: default;
  position: relative;
}
.history-item:hover { background: var(--panel-2); }
.history-item .dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.history-item.manual    .dot { background: var(--accent); }
.history-item.llm-post  .dot { background: var(--ok); }
.history-item.llm-pre   .dot { background: #888; }
.history-item.pre-save  .dot { background: #555; }
.history-item .body {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.history-item .label {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item .meta {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.history-item .restore-btn {
  flex: none;
  padding: 2px 8px;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.15s;
}
.history-item:hover .restore-btn { opacity: 1; }
.history-item .restore-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* Toast (LLM-post notification, errors, status) */
.toast-container {
  position: fixed;
  top: 60px;
  right: 14px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 360px;
}
.toast {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: toast-in 0.18s ease-out;
}
.toast.llm-post { border-left-color: var(--ok); }
.toast .toast-msg { line-height: 1.4; white-space: pre-line; }
.toast .toast-actions { display: flex; gap: 6px; justify-content: flex-end; }
.toast .toast-actions button { padding: 4px 10px; font-size: 12px; }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* Profile switcher (topbar) */
.profile-switcher { position: relative; }
.profile-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 12px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-btn:hover { background: var(--panel-2); }
.profile-btn.active-profile { border-color: var(--accent); color: var(--accent); }
.profile-arrow { font-size: 10px; color: var(--muted); flex: none; }
.profile-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 260px;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  z-index: 150;
  overflow: hidden;
}
.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.profile-dropdown-item:last-child { border-bottom: none; }
.profile-dropdown-item:hover { background: var(--panel-2); }
.profile-dropdown-item.is-active { color: var(--accent); font-weight: 600; }
.profile-dropdown-item .dot {
  flex: none; width: 7px; height: 7px;
  border-radius: 50%; background: var(--border);
}
.profile-dropdown-item.is-active .dot { background: var(--accent); }
.profile-dropdown-item .item-label { flex: 1 1 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-dropdown-item .no-key { font-size: 11px; color: var(--error); flex: none; }
.profile-dropdown-add {
  padding: 9px 14px;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  text-align: center;
}
.profile-dropdown-add:hover { background: var(--panel-2); }

/* Settings modal — profile row */
.settings-header { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.settings-profile-row { display: flex; align-items: center; gap: 6px; }
.cfg-profile-select { flex: 1 1 0; font-size: 13px; padding: 6px 8px; }
.danger-btn { background: transparent; border-color: var(--error); color: var(--error); padding: 6px 10px; }
.danger-btn:hover { background: var(--error); color: #fff; border-color: var(--error); }
.cfg-label-preview {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  background: var(--panel-2);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.cfg-label-preview strong { color: var(--text); }
.cfg-policy {
  margin: 0 0 4px;
  padding: 8px 12px;
  font-size: 12px;
  background: rgba(91, 156, 255, 0.07);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  line-height: 1.5;
}
.cfg-policy code {
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

/* Token usage pill in workspace topbar */
.usage-cluster {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.usage-pill {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: default;
}
.usage-cluster:hover .usage-pill { border-color: var(--accent); color: var(--text); }
.usage-calc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  background: var(--panel-2);
  cursor: pointer;
  user-select: none;
}
.usage-calc:hover { border-color: var(--accent); background: var(--panel); }

/* Hover popover with model breakdown */
.usage-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 280px;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  padding: 10px 12px;
  font-size: 12px;
  z-index: 150;
}
.usage-tooltip .ut-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 6px;
}
.usage-tooltip .ut-total {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.usage-tooltip .ut-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 3px 0;
  font-variant-numeric: tabular-nums;
}
.usage-tooltip .ut-row .ut-model {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.usage-tooltip .ut-row .ut-tokens { color: var(--muted); }
.usage-tooltip .ut-row .ut-turns  { color: var(--muted); font-size: 11px; }
.usage-tooltip .ut-empty { color: var(--muted); font-style: italic; padding: 6px 0; }
.usage-tooltip .ut-archive {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}

/* Per-message footer (model + tokens) shown under each assistant turn */
.msg-meta {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg-meta .meta-tokens { color: var(--text); opacity: 0.85; }
.msg-meta .meta-model {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}

/* Template picker modal */
.modal-wide { width: 720px; max-width: 92vw; }
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 8px;
}
.template-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 18px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
  min-height: 110px;
}
.template-card:hover {
  border-color: var(--accent);
  background: var(--accent-softer);
  transform: translateY(-2px);
}
.template-card .template-icon {
  font-size: 22px;
  color: var(--accent);
  margin-bottom: 4px;
}
.template-card .template-name {
  font-size: 14px;
  font-weight: 600;
}
.template-card .template-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

@media (max-width: 640px) {
  .template-grid { grid-template-columns: repeat(2, 1fr); }
}

.import-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  margin: 12px 0 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.import-banner:hover {
  border-color: var(--accent);
  background: var(--accent-softer);
  transform: translateY(-1px);
}
.import-banner-icon { font-size: 22px; }
.import-banner-body { flex: 1; min-width: 0; }
.import-banner-title { font-size: 14px; font-weight: 600; }
.import-banner-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.import-banner-chevron { color: var(--muted); font-size: 20px; }

.import-panel {
  margin: 12px 0;
  padding: 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.import-panel-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.import-panel-label input {
  padding: 9px 11px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  font: inherit;
}
.import-panel-hint { font-size: 12px; line-height: 1.5; }
.import-panel-error {
  font-size: 12px;
  color: #ff8a8a;
  background: rgba(255, 100, 100, 0.08);
  border: 1px solid rgba(255, 100, 100, 0.3);
  border-radius: 6px;
  padding: 8px 10px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* ---------- Publish / Releases (Phase 4b) ---------- */
/* Three states drive the gradient: default = "게시됨"(blue), .dirty = 재게시
   필요(orange), .draft = 아직 미게시(gray). White text + 1px inner shadow on
   hover keeps the label legible against any theme background. */
.publish-btn {
  background: linear-gradient(135deg, #4ea8ff, #5b9cff);
  color: #ffffff;
  border: 1px solid transparent;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(11,31,58,0.10);
  transition: filter .12s ease, transform .12s ease, box-shadow .12s ease;
}
/* Hover MUST re-declare the gradient. beany.css ships a generic
   `button:hover { background: var(--bg-muted) }` that wins specificity
   otherwise — turning the button into a gray pill with white text. */
.publish-btn:hover {
  background: linear-gradient(135deg, #4ea8ff, #5b9cff);
  filter: brightness(0.92);
  box-shadow: 0 2px 6px rgba(11,31,58,0.16);
  transform: translateY(-1px);
}
.publish-btn:active { transform: translateY(0); filter: brightness(0.86); }
.publish-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.publish-btn.dirty            { background: linear-gradient(135deg, #ff9a4e, #ff7e3a); }
.publish-btn.dirty:hover      { background: linear-gradient(135deg, #ff9a4e, #ff7e3a); }
.publish-btn.draft            { background: linear-gradient(135deg, #8a8f99, #6a7282); }
.publish-btn.draft:hover      { background: linear-gradient(135deg, #8a8f99, #6a7282); }
.publish-status {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 10px 0 12px;
  font-size: 13px;
  line-height: 1.6;
}
.publish-status .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
}
.publish-status .badge.draft { background: #888; color: white; }
.publish-status .badge.published { background: #2e9c5e; color: white; }
.publish-status .badge.dirty { background: #d77a2c; color: white; }
.publish-status .pub-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.publish-status .pub-hint { margin-top: 6px; color: var(--text-muted); font-size: 12.5px; }

/* The published URL block: high-contrast pill that reads clearly in both
   themes regardless of :visited state. The anchor color is forced (no
   default purple) so the URL never blends into the background. */
.publish-status .pub-url-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 10px;
}
.publish-status .pub-url-label {
  flex: 0 0 auto;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.publish-status a.pub-url,
.publish-status a.pub-url:link,
.publish-status a.pub-url:visited,
.publish-status a.pub-url:hover,
.publish-status a.pub-url:active {
  flex: 1 1 0; min-width: 0;
  color: var(--text-strong);
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
  text-decoration: none;
  white-space: normal;
  word-break: break-all;
  overflow-wrap: anywhere;
}
.publish-status a.pub-url:hover { text-decoration: underline; color: var(--accent); }
.publish-status .pub-copy-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px;
  font-size: 12px; font-weight: 500;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}
.publish-status .pub-copy-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.publish-status .pub-copy-btn.copied { background: #2e9c5e; border-color: #2e9c5e; color: white; }
.publish-status .pub-copy-icon { font-size: 13px; line-height: 1; }
.publish-form label { display: block; margin: 6px 0 12px; font-size: 12px; color: var(--muted); }
.publish-form input { width: 100%; box-sizing: border-box; padding: 8px 10px;
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  color: inherit; font: inherit; margin-top: 4px; }
.publish-history-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.release-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.release-row:last-child { border-bottom: none; }
.release-row .ver { font-weight: 700; min-width: 40px; }
.release-row .label { flex: 1; color: var(--muted); }
.release-row .when { font-size: 11px; color: var(--muted); }
.release-row .active-pill {
  font-size: 10px; background: #2e9c5e; color: white;
  padding: 2px 6px; border-radius: 999px; font-weight: 600;
}
.release-row button { font-size: 11px; padding: 4px 8px; }

/* Phase 4b-iii: diff + pin */
.publish-diff {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  max-height: 220px;
  overflow-y: auto;
}
.publish-diff h4 { margin: 6px 0 4px; font-size: 12px; }
.publish-diff .file { padding: 1px 0; }
.publish-diff .added    { color: #2e9c5e; }
.publish-diff .removed  { color: #c0392b; }
.publish-diff .modified { color: #d77a2c; }
.release-row .pin-toggle {
  cursor: pointer;
  font-size: 14px;
  opacity: 0.4;
  background: none;
  border: none;
  padding: 2px 6px;
}
.release-row .pin-toggle.pinned { opacity: 1; color: #d77a2c; }
.release-row .delete-btn {
  font-size: 11px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.release-row .delete-btn:hover { color: #c0392b; border-color: #c0392b; }

/* ---------- Credit & referral card (Phase 11 Step 4) ---------- */
.credit-card .credit-balance-row { display:flex; align-items:baseline; gap:12px; flex-wrap:wrap; margin:14px 0 18px; }
.credit-card .credit-balance { font-size:28px; font-weight:700; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }
.credit-card .credit-hint { font-size:13px; }
.credit-card .referral-row { border-top:1px solid var(--border); padding-top:14px; }
.credit-card .referral-label { font-size:13px; margin-bottom:6px; }
.credit-card .referral-url-row { display:flex; gap:8px; align-items:center; }
.credit-card .referral-url-row input {
  flex:1; padding:9px 11px; border:1px solid var(--border); border-radius:8px;
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:13px; background:var(--panel-2);
}
.credit-card .referral-url-row button {
  padding:9px 14px; border:1px solid var(--border); border-radius:8px; background:white; cursor:pointer; font-size:13px;
}
.credit-card .referral-stats { font-size:12px; margin-top:8px; }
.credit-card .bonus-progress { margin-top:14px; border-top:1px solid var(--border); padding-top:14px; }
.credit-card .bonus-progress-head { margin:0 0 8px; font-size:13px; color:var(--muted); font-weight:600; }
.credit-card .bonus-progress-table { width:100%; border-collapse:collapse; font-size:13px; border:1px solid var(--border); border-radius:8px; overflow:hidden; }
.credit-card .bonus-progress-table th,
.credit-card .bonus-progress-table td { padding:8px 10px; text-align:left; border-bottom:1px solid var(--border); }
.credit-card .bonus-progress-table tr:last-child td { border-bottom:none; }
.credit-card .bonus-progress-table th { background:var(--panel-2); font-size:12px; color:var(--muted); font-weight:600; }
.credit-card .bonus-progress-table td.amt,
.credit-card .bonus-progress-table td.total { text-align:right; font-variant-numeric:tabular-nums; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }
.credit-card .bonus-progress-table td.total { color:#1c8a45; font-weight:600; }
.credit-card .bonus-progress-table td.total.zero { color:var(--muted); font-weight:400; }
.credit-card .bonus-progress-table .status-claimed { color:#1c8a45; font-weight:600; }
.credit-card .bonus-progress-table .status-pending { color:var(--muted); }
.credit-card .bonus-history { margin-top:14px; border-top:1px solid var(--border); padding-top:12px; }
.credit-card .bonus-history summary { cursor:pointer; font-size:13px; color:var(--muted); }
.credit-card .bonus-history-list { list-style:none; margin:8px 0 0; padding:0; display:flex; flex-direction:column; gap:6px; font-size:13px; }
.credit-card .bonus-history-list li { display:flex; justify-content:space-between; padding:6px 10px; background:var(--panel-2); border-radius:6px; }
.credit-card .bonus-history-list .delta { font-weight:600; color:#1c8a45; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }
.credit-card .bonus-history-empty { margin-top:8px; font-size:13px; }

/* ---------- Address card (Phase 10f-1) ---------- */
.address-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  margin: 18px 0 26px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.address-card-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; flex-wrap:wrap; margin-bottom:12px; }
.address-card-head h2 { margin:0 0 4px; font-size:17px; font-weight:600; }
.address-card .muted { color:var(--muted); font-size:13px; margin:0; }
/* Report modal (shared between gallery / app detail). */
.bw-report-modal { position:fixed; inset:0; z-index:1100; display:flex;
  align-items:center; justify-content:center; padding:20px; }
.bw-report-modal.hidden { display:none; }
.bw-report-modal .bw-report-backdrop { position:absolute; inset:0;
  background:rgba(0,0,0,0.55); }
.bw-report-modal .bw-report-card { position:relative; max-width:440px; width:100%;
  background:var(--surface, #fff); color:var(--text); border-radius:14px;
  padding:24px; box-shadow:0 16px 48px rgba(0,0,0,0.25);
  border:1px solid var(--border); }
.bw-report-modal h2 { margin:0 0 6px; font-size:18px; color:var(--text-strong); }
.bw-report-modal .bw-report-desc { margin:0 0 16px; font-size:13px; color:var(--muted); }
.bw-report-modal .bw-report-reasons { border:0; padding:0; margin:0 0 16px;
  display:flex; flex-direction:column; gap:8px; }
.bw-report-modal .bw-report-reason { display:flex; align-items:center; gap:10px;
  padding:9px 12px; border:1px solid var(--border); border-radius:8px;
  font-size:14px; cursor:pointer; transition:background .12s, border-color .12s; }
.bw-report-modal .bw-report-reason:hover { border-color:var(--accent); }
.bw-report-modal .bw-report-reason:has(input:checked) {
  border-color:var(--accent); background:var(--accent-soft); color:var(--accent); }
.bw-report-modal .bw-report-reason input { margin:0; accent-color:var(--accent); }
.bw-report-modal .bw-report-details-label { display:block; font-size:12px;
  font-weight:600; color:var(--text-strong); margin-bottom:6px; }
.bw-report-modal textarea { width:100%; box-sizing:border-box; resize:vertical;
  background:var(--bg-muted, var(--panel-2)); border:1px solid var(--border);
  border-radius:8px; padding:8px 10px; font:13.5px/1.5 inherit; color:var(--text); }
.bw-report-modal textarea:focus { outline:none; border-color:var(--accent); }
.bw-report-modal .bw-report-status { min-height:18px; font-size:12.5px; margin-top:10px; }
.bw-report-modal .bw-report-status.ok  { color:#2a8c4a; }
.bw-report-modal .bw-report-status.err { color:#c0392b; }
.bw-report-modal .bw-report-actions { display:flex; gap:8px; justify-content:flex-end;
  margin-top:14px; }
.bw-report-modal .bw-btn-primary, .bw-report-modal .bw-btn-ghost {
  padding:9px 18px; border-radius:8px; font-size:14px; font-weight:600;
  cursor:pointer; border:1px solid transparent; }
.bw-report-modal .bw-btn-primary { background:var(--accent); color:#fff; border-color:var(--accent); }
.bw-report-modal .bw-btn-primary:hover { filter:brightness(1.05); }
.bw-report-modal .bw-btn-primary:disabled { opacity:0.5; cursor:not-allowed; }
.bw-report-modal .bw-btn-ghost { background:transparent; color:var(--text);
  border-color:var(--border-strong); }
.bw-report-modal .bw-btn-ghost:hover { background:var(--accent-soft); }

/* Onboarding banner — shown on /me when user has no addresses yet. */
.onboarding-banner {
  display:flex; align-items:center; gap:16px;
  padding:18px 22px; margin-bottom:20px;
  border:1px solid var(--accent); border-radius:14px;
  background:linear-gradient(135deg, var(--accent-soft), var(--panel-2));
  box-shadow:0 2px 10px rgba(0,0,0,0.04);
}
.onboarding-banner.hidden { display:none; }
.onboarding-banner .ob-icon { font-size:34px; line-height:1; flex-shrink:0; }
.onboarding-banner .ob-body { flex:1; min-width:0; }
.onboarding-banner .ob-body h2 { font-size:16px; margin:0 0 4px; color:var(--text-strong); }
.onboarding-banner .ob-body p { font-size:13px; margin:0; color:var(--muted); line-height:1.5; }
.onboarding-banner button.primary { flex-shrink:0; padding:10px 18px; border-radius:10px; border:0;
  background:var(--accent); color:#fff; font-weight:600; font-size:14px; cursor:pointer; }
.onboarding-banner button.primary:hover { filter:brightness(1.05); }
@media (max-width: 560px) {
  .onboarding-banner { flex-direction:column; align-items:stretch; text-align:left; }
  .onboarding-banner button.primary { width:100%; }
}

.address-list { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; }
.address-list:empty { margin:0; }
.address-row {
  display:flex; align-items:center; flex-wrap:wrap; gap:8px 12px;
  padding:10px 14px; border:1px solid var(--border); border-radius:10px; background:var(--panel-2);
}
.address-row .handle-text { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:14px; font-weight:500; }
.address-row .addr-cell { flex:1 1 220px; display:flex; flex-direction:column; min-width:0; gap:2px; }
.address-row .addr-domain {
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:14px; color:var(--text);
  word-break:break-all; overflow-wrap:anywhere; line-height:1.4;
}
.address-row .addr-domain b { font-weight:700; color:var(--accent); }
.address-row .addr-handle { font-size:11px; color:var(--muted); word-break:break-all; }
.address-row .primary-tag {
  display:inline-block; padding:2px 8px; border-radius:999px;
  background:var(--accent-soft); color:var(--accent); font-size:11px; font-weight:600;
  flex:0 0 auto;
}
.address-row .row-spacer { flex:1 1 0; }
.address-row button { background:transparent; border:1px solid var(--border); border-radius:6px; padding:4px 10px; font-size:12px; color:var(--muted); cursor:pointer; flex:0 0 auto; }
.address-row button:hover { color:var(--text); border-color:var(--accent); }
.address-row .release-btn:hover { color:#c0392b; border-color:#c0392b; }
.address-quota { margin-top:10px; font-size:12px; }
.address-empty { padding:12px 0 4px; }

.handle-modal { max-width:420px; }
.handle-modal h3 { margin-top:0; }
.handle-input-row { display:flex; align-items:stretch; border:1px solid var(--border); border-radius:8px; overflow:hidden; margin-top:14px; }
.handle-input-row .prefix { padding:8px 10px; background:var(--panel-2); color:var(--muted); font-size:13px; font-family:ui-monospace,monospace; white-space:nowrap; }
.handle-input-row input { flex:1; border:none; outline:none; padding:8px 10px; font-family:ui-monospace,monospace; font-size:14px; background:transparent; color:var(--text); }
.handle-status { min-height:18px; font-size:12px; margin-top:8px; }
.handle-status.ok  { color:#2a8c4a; }
.handle-status.err { color:#c0392b; }
.handle-preview { font-size:12px; margin-top:8px; line-height:1.7; padding:8px 10px;
                  background:var(--panel-2); border-radius:6px;
                  font-family:ui-monospace,monospace; color:var(--muted); }
.handle-preview b { color:var(--text); font-weight:600; }
.handle-primary { display:flex; align-items:center; gap:8px; margin-top:14px; font-size:13px; color:var(--muted); }
.handle-modal .modal-actions { margin-top:18px; display:flex; gap:8px; justify-content:flex-end; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); border:0; }

/* ---------- Publish modal address fields (Phase 10f-2) ---------- */
.publish-address,
.publish-listing {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px 10px;
  margin: 0 0 14px;
}
.publish-listing legend { padding:0 6px; font-size:12px; color:var(--muted); font-weight:600; }
.publish-listing label { display:block; margin:6px 0 10px; font-size:12px; color:var(--muted); }
.publish-listing input,
.publish-listing textarea {
  width:100%; box-sizing:border-box; padding:8px 10px; border:1px solid var(--border);
  border-radius:6px; background:var(--panel-2); color:var(--text); font:inherit; font-size:13px;
  margin-top:4px;
}
.publish-listing textarea { resize:vertical; min-height:80px; font-family:inherit; }
.publish-listing .addr-status { min-height:16px; font-size:12px; margin-top:4px; }
.publish-shots { margin-top:10px; }
.publish-shots-head { display:flex; align-items:center; justify-content:space-between; gap:10px;
                      font-size:12px; color:var(--muted); margin-bottom:6px; }
.publish-shots-add { background:var(--panel-2); border:1px solid var(--border); border-radius:6px;
                     padding:4px 10px; font-size:12px; cursor:pointer; color:var(--text); }
.publish-shots-add:hover { border-color:var(--accent); color:var(--accent); }
.publish-shots-list { display:flex; flex-wrap:wrap; gap:8px; }
.publish-shots-list:empty::before { content:'아직 없음'; color:var(--muted); font-size:12px; }
.publish-shot { position:relative; width:100px; height:62px; border-radius:6px; overflow:hidden;
                border:1px solid var(--border); background:var(--panel-2); }
.publish-shot img { width:100%; height:100%; object-fit:cover; display:block; }
.publish-shot-actions { position:absolute; inset:auto 2px 2px 2px; display:flex; gap:2px;
                        justify-content:space-between; }
.publish-shot-actions button { background:rgba(0,0,0,0.6); color:#fff; border:0; border-radius:4px;
                                font-size:11px; padding:2px 6px; cursor:pointer; }
.publish-shot-actions button:hover { background:rgba(0,0,0,0.85); }
.publish-shot-del { background:rgba(180,40,40,0.85)!important; }
.publish-address legend { padding: 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.publish-address .addr-row { display:flex; align-items:center; gap:10px; margin:6px 0; }
.publish-address .addr-row label { width:48px; font-size:12px; color:var(--muted); }
.publish-address select,
.publish-address input { flex:1; padding:6px 10px; border:1px solid var(--border); border-radius:6px; background:var(--panel-2); color:var(--text); font:inherit; font-family:ui-monospace,monospace; font-size:13px; }
.publish-address .addr-status { min-height:16px; font-size:12px; margin-top:4px; }
.publish-address .addr-status.ok  { color:#2a8c4a; }
.publish-address .addr-status.err { color:#c0392b; }
.publish-address .addr-preview { margin-top:6px; padding:6px 10px; background:var(--panel-2); border-radius:6px; font:13px ui-monospace,monospace; color:var(--muted); }
.publish-address .addr-help { margin:8px 0 0; font-size:12px; }
.publish-address .addr-help a { color:var(--accent); text-decoration:underline; }
.publish-address .addr-home-toggle {
  display:flex; align-items:flex-start; gap:10px;
  margin:12px 0 4px; padding:10px 12px;
  border:1px solid var(--border); border-radius:8px;
  background:var(--panel-2); cursor:pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.publish-address .addr-home-toggle:hover { border-color:var(--border-strong); }
.publish-address .addr-home-toggle:has(input:checked) {
  border-color: var(--accent); background: var(--accent-tint);
}
.publish-address .addr-home-toggle input[type="checkbox"] {
  width:16px !important; height:16px !important; flex:0 0 16px;
  padding:0 !important; margin:2px 0 0 !important; cursor:pointer;
}
.publish-address .addr-home-label { display:flex; flex-direction:column; gap:2px; line-height:1.4; }
.publish-address .addr-home-title { font-size:13px; font-weight:600; color:var(--text); }
.publish-address .addr-home-help  { font-size:12px; color:var(--muted); }
.publish-address .addr-home-help code {
  padding:1px 5px; border-radius:4px; background:var(--panel); font-size:11px;
}

/* ---------- Recovery codes (Phase A) ---------- */
.recovery-modal { max-width: 460px; }
.recovery-modal h3 { margin-top:0; }
.recovery-modal .warn {
  background: rgba(255,180,60,.12);
  border: 1px solid rgba(255,180,60,.45);
  color: var(--text);
  padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height:1.5;
  margin: 0 0 14px;
}
.recovery-list {
  list-style: none; margin: 0 0 12px; padding: 12px 14px;
  background: var(--panel-2); border-radius: 8px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px; letter-spacing: 0.06em;
}
.recovery-list li {
  padding: 4px 0; color: var(--text); user-select: all;
}
.recovery-actions { display:flex; gap:8px; margin-bottom: 12px; }
.recovery-actions button {
  flex: 1; padding: 6px 10px; border:1px solid var(--border); border-radius:6px;
  background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 12px;
}
.recovery-actions button:hover { border-color: var(--accent); }
.recovery-ack { display:flex; gap:8px; align-items:center; font-size:13px; margin-bottom: 10px; }

/* ============================================================
   Mobile workspace — single-pane fullscreen with tab switcher.
   ≤768px 에만 적용. 그 이상은 기존 데스크탑 grid 그대로.
   ============================================================ */
.mobile-tabs { display: none; }

@media (max-width: 768px) {
  .mobile-tabs {
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 48px; z-index: 30;
  }
  .mobile-tabs button {
    flex: 1;
    padding: 8px 10px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px; font-weight: 500;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    position: relative;
  }
  .mobile-tabs button.is-active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }
  .mpane-dot {
    display: inline-block;
    width: 7px; height: 7px;
    background: #ff4d4f;
    border-radius: 50%;
    margin-left: 4px;
  }

  /* dvh 로 키보드 올라와도 패널이 화면 안에 머묾 */
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    height: calc(100dvh - 48px - 49px);  /* 48 헤더 + 49 모바일 탭 */
  }
  /* files-hidden body 클래스가 있어도 모바일에선 무시 — 탭으로 제어 */
  body.files-hidden .layout { grid-template-columns: 1fr; }
  body.files-hidden .files-pane { display: none; }

  .chat, .files-pane, .preview {
    grid-column: 1; grid-row: 1;
    display: none;
    min-width: 0;
  }
  body.mpane-chat    .chat        { display: flex; }
  body.mpane-preview .preview     { display: flex; }
  body.mpane-files   .files-pane  { display: flex; }

  /* 탭바가 헤더 일부 컨트롤을 대체하므로 데스크탑 전용 버튼은 숨김 */
  #files-toggle { display: none; }

  /* Mobile-only: shorter textarea so the composer never exceeds visible
     height when the soft keyboard is up. Combined with `.composer
     flex: 0 0 auto`, this guarantees the Send button stays on screen. */
  .composer textarea { max-height: 120px; min-height: 56px; }
  .composer { padding: 10px; gap: 8px; }

  /* iOS Safari auto-zooms the page on focus when an input/textarea text
     is < 16px, which makes the field look like it suddenly grew. Set
     16px globally on mobile to disable that behavior; visual sizing is
     unchanged because all our small inputs are already close to 14-15px
     and the bump is invisible on a phone. Bumping rem/em would not help
     — Safari checks the *computed* px value. */
  input, textarea, select { font-size: 16px; }
}

/* ============================================================
   Mobile — header trim + publish modal sizing
   ============================================================ */
@media (max-width: 768px) {
  /* 헤더 좁힘 */
  .topbar { padding: 0 8px; gap: 8px; }
  .topbar > .back-link span { display: none; }   /* 아이콘만 */
  .app-name { font-size: 14px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 모바일에서 숨길 비핵심 버튼 (필요할 때만 노출 가능하게 별도 토글 안 만들고 일단 정리) */
  #open-preview-btn,
  #reload-btn,
  #theme-toggle,
  .usage-cluster,
  .profile-switcher { display: none; }

  /* 핵심은 표시: 🚀 게시 + ⚙ 설정 + 크레딧 */
  .publish-btn { padding: 8px 12px; font-size: 13px; }
  #settings-btn { padding: 6px 8px; }
  #credit-chip { padding: 4px 8px; font-size: 12px; }

  /* 모달 — 풀스크린 가깝게, 안전영역 적용 */
  .modal-backdrop { align-items: stretch; padding: 0; }
  .modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    padding: 16px 14px;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    gap: 14px;
  }
  .modal h2 { font-size: 18px; }

  /* 게시 모달 — 액션 버튼 줄바꿈 허용, 터치 영역 확대 */
  .modal-actions {
    flex-wrap: wrap;
    justify-content: stretch;
    gap: 8px;
  }
  .modal-actions button {
    flex: 1 1 calc(50% - 4px);
    min-height: 44px;
    font-size: 14px;
  }
  .modal-actions button.primary { flex-basis: 100%; order: -1; } /* 주 버튼 위로 + 풀폭 */

  /* 입력 필드 터치 영역 */
  .publish-form input[type="text"],
  .publish-form select {
    min-height: 44px;
    font-size: 15px;  /* iOS auto-zoom 방지 (≥16px 권장이지만 15px 도 대체로 OK) */
  }

  /* publish 주소 미리보기는 모바일에서 줄바꿈 허용 */
  .publish-status .pub-url-row { flex-wrap: wrap; }
  .publish-status .pub-url-row .pub-url { flex: 1 1 100%; }
}

/* Publish 모달 — inline 핸들 생성 */
.addr-create {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px dashed var(--border-strong, var(--border));
  border-radius: 8px;
}
.addr-create.hidden { display: none; }
.addr-create input[type="text"] {
  flex: 1; min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
}
.addr-create button.primary {
  background: var(--accent); color: white; border: none;
  padding: 8px 12px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.addr-create button:not(.primary) {
  background: transparent; border: 1px solid var(--border);
  padding: 8px 10px; border-radius: 6px; font-size: 13px; cursor: pointer;
  color: var(--text);
}
.link-btn {
  background: transparent;
  border: none;
  color: var(--accent, #4ea8ff);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
}
.link-btn:hover { text-decoration: underline; }
.addr-status.ok { color: #2e9c5e; }
.addr-status.err { color: #c0392b; }

/* Site footer (footer.js) — minimal legal-link bar. */
.site-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 6px 16px; padding: 24px 16px; margin-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--text-faint); font-size: 12.5px; text-align: center;
}
.site-footer .sf-brand { color: var(--text-faint); }
.site-footer .sf-beta {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 999px;
  padding: 0 6px; margin: 0 2px; vertical-align: middle;
}
.site-footer .sf-links { display: inline-flex; flex-wrap: wrap; gap: 6px 14px; }
.site-footer .sf-links a { color: var(--text-muted); text-decoration: none; }
.site-footer .sf-links a:hover { color: var(--accent); text-decoration: underline; }
