/* ============================================================================
   UnivDash 화면 전용 스타일 — theme.css(공통 테마) 위에 얹는다.
   모바일 우선: 화면 높이는 visualViewport 기준(--app-h)으로 맞춰 키보드가 올라와도
   입력창이 가려지지 않게 한다.
   ============================================================================ */
:root { --app-h: 100%; --vv-top: 0px; --term-font: 12px; --shell-bg: #070a13; }
html[data-ui-theme-mode="light"] { --shell-bg: #eef0f7; }
html[data-ui-theme="mono"]:not([data-ui-theme-mode="light"]) { --shell-bg: #0b0e14; }
html[data-ui-theme="mono"][data-ui-theme-mode="light"] { --shell-bg: #f3f4f6; }

html, body.app-shell { height: var(--app-h); overscroll-behavior: none; }
body.app-shell { min-height: 0; }
button, a, .key-chip, [role="button"] { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }
/* 노치 · 상태바 · 홈 인디케이터 영역. Tailwind(h-14, p-5 등)가 CSS 순서상 뒤에 오므로 !important 로 이긴다.
   (홈 화면 앱에서만 inset 이 0 이 아니라 Safari 탭에서는 티가 안 나던 문제) */
.safe-bottom { padding-bottom: max(0.5rem, env(safe-area-inset-bottom)) !important; }
.safe-top { padding-top: max(1.25rem, env(safe-area-inset-top)) !important; }
header.safe-top-header { padding-top: env(safe-area-inset-top) !important; height: calc(3.5rem + env(safe-area-inset-top)) !important; }

/* 데스크톱에서 사이드바 접기 */
@media (min-width: 768px) {
    body.sidebar-collapsed #sidebar { display: none; }
}

/* ── 필터 칩 ─────────────────────────────────────────────────────── */
.filter-chip {
    display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
    padding: 6px 12px; border-radius: 999px;
    font-size: 12px; font-weight: 700; white-space: nowrap;
    border: 1px solid rgba(255,255,255,0.10); background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.55); transition: background 150ms, color 150ms, border-color 150ms;
}
.filter-chip span:empty { display: none; }
.filter-chip span { font-family: 'JetBrains Mono', monospace; font-size: 10px; opacity: 0.8; }
.filter-chip:hover { background: rgba(255,255,255,0.08); color: #fff; }
.filter-chip.active, .filter-chip[aria-pressed="true"] { background: rgba(59,130,246,0.15); border-color: rgba(96,165,250,0.35); color: #93c5fd; }
html[data-ui-theme-mode="light"] .filter-chip { border-color: rgba(15,23,42,0.10); background: rgba(15,23,42,0.03); color: #47536e; }
html[data-ui-theme-mode="light"] .filter-chip:hover { background: rgba(15,23,42,0.07); color: #101828; }
html[data-ui-theme-mode="light"] .filter-chip.active,
html[data-ui-theme-mode="light"] .filter-chip[aria-pressed="true"] { background: rgba(59,130,246,0.10); border-color: rgba(37,99,235,0.3); color: #1d4ed8; }

/* ── 창 목록 ─────────────────────────────────────────────────────── */
.folder-head {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 6px 8px; border-radius: 10px; text-align: left;
    font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
    color: rgba(255,255,255,0.5);
}
.folder-head:hover { background: rgba(255,255,255,0.04); }
html[data-ui-theme-mode="light"] .folder-head { color: #5a6781; }
html[data-ui-theme-mode="light"] .folder-head:hover { background: rgba(15,23,42,0.04); }
.folder-caret { transition: transform 150ms; font-size: 9px; width: 10px; }
.collapsed .folder-caret { transform: rotate(-90deg); }

.win-item {
    position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
    min-height: 60px; padding: 10px 8px 10px 12px; border-radius: 14px; text-align: left;
    border: 1px solid transparent; transition: background 120ms, border-color 120ms;
    user-select: none; -webkit-user-select: none;
}
.win-item:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.06); }
.win-item:active { background: rgba(255,255,255,0.08); }
.win-item.selected { background: rgba(59,130,246,0.13); border-color: rgba(96,165,250,0.30); }
.win-item.is-hidden { opacity: 0.45; }
html[data-ui-theme-mode="light"] .win-item:hover { background: rgba(15,23,42,0.04); border-color: rgba(15,23,42,0.06); }
html[data-ui-theme-mode="light"] .win-item.selected { background: rgba(59,130,246,0.10); border-color: rgba(37,99,235,0.25); }
.win-more {
    width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.35);
}
.win-more:hover { background: rgba(255,255,255,0.08); color: #fff; }
html[data-ui-theme-mode="light"] .win-more { color: #8a92aa; }
html[data-ui-theme-mode="light"] .win-more:hover { background: rgba(15,23,42,0.07); color: #101828; }
.unread-dot { position: absolute; top: 9px; left: 7px; width: 7px; height: 7px; border-radius: 50%; background: #60a5fa; box-shadow: 0 0 0 2px var(--shell-bg); }

/* 상태 아이콘 */
.status-icon {
    width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.st-idle    { background: rgba(16,185,129,0.12); color: #34d399; }
.st-busy    { background: rgba(59,130,246,0.15); color: #60a5fa; }
.st-waiting { background: rgba(245,158,11,0.16); color: #fbbf24; }
.st-shell   { background: rgba(148,163,184,0.12); color: #94a3b8; }
.st-dead    { background: rgba(239,68,68,0.12); color: #f87171; }
html[data-ui-theme-mode="light"] .st-idle { color: #059669; }
html[data-ui-theme-mode="light"] .st-busy { color: #2563eb; }
html[data-ui-theme-mode="light"] .st-waiting { color: #b45309; }
html[data-ui-theme-mode="light"] .st-shell { color: #64748b; }
.st-waiting { animation: tdxPulse 1.6s ease-in-out infinite; }
@keyframes tdxPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.35); } 50% { box-shadow: 0 0 0 5px rgba(245,158,11,0); } }

.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #64748b; }
.status-dot.idle { background: #10b981; box-shadow: 0 0 10px rgba(16,185,129,0.6); }
.status-dot.busy { background: #3b82f6; box-shadow: 0 0 10px rgba(59,130,246,0.7); animation: tdxBlink 1s ease-in-out infinite; }
.status-dot.waiting { background: #f59e0b; box-shadow: 0 0 10px rgba(245,158,11,0.7); animation: tdxBlink 1.4s ease-in-out infinite; }
.status-dot.dead { background: #ef4444; }
@keyframes tdxBlink { 50% { opacity: 0.35; } }

.agent-pill {
    flex-shrink: 0; display: inline-flex; align-items: center;
    padding: 1px 6px; border-radius: 6px; font-size: 9px; font-weight: 800; letter-spacing: 0.06em;
    font-family: 'JetBrains Mono', monospace; text-transform: uppercase;
}
.agent-claude { color: #f0a080; background: rgba(217,119,87,0.16); border: 1px solid rgba(217,119,87,0.30); }
.agent-codex  { color: #4fd1a5; background: rgba(16,163,127,0.16); border: 1px solid rgba(16,163,127,0.30); }
.agent-shell  { color: #94a3b8; background: rgba(148,163,184,0.12); border: 1px solid rgba(148,163,184,0.2); }
html[data-ui-theme-mode="light"] .agent-claude { color: #b4532f; }
html[data-ui-theme-mode="light"] .agent-codex { color: #0b7a5f; }
html[data-ui-theme-mode="light"] .agent-shell { color: #475569; }

/* 폴더 색상 */
.fc-blue { color: #60a5fa; } .fc-purple { color: #c084fc; } .fc-emerald { color: #34d399; }
.fc-amber { color: #fbbf24; } .fc-rose { color: #fb7185; } .fc-cyan { color: #22d3ee; } .fc-slate { color: #94a3b8; }
.fb-blue { background: #3b82f6; } .fb-purple { background: #a855f7; } .fb-emerald { background: #10b981; }
.fb-amber { background: #f59e0b; } .fb-rose { background: #f43f5e; } .fb-cyan { background: #06b6d4; } .fb-slate { background: #64748b; }

/* ── 터미널 패널 ─────────────────────────────────────────────────── */
.term-shell { background: transparent; }
#termView.open { display: flex; }
.term-tool {
    width: 38px; height: 38px; flex-shrink: 0; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.55); transition: background 150ms, color 150ms;
}
.term-tool:hover { background: rgba(255,255,255,0.08); color: #fff; }
html[data-ui-theme-mode="light"] .term-tool { color: #47536e; }
html[data-ui-theme-mode="light"] .term-tool:hover { background: rgba(15,23,42,0.07); color: #101828; }

.pane-tab {
    flex-shrink: 0; padding: 4px 10px; border-radius: 8px; font-size: 11px; font-weight: 700;
    font-family: 'JetBrains Mono', monospace; color: rgba(255,255,255,0.5);
    border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.03);
}
.pane-tab.active { color: #93c5fd; border-color: rgba(96,165,250,0.35); background: rgba(59,130,246,0.14); }
html[data-ui-theme-mode="light"] .pane-tab { color: #5a6781; border-color: rgba(15,23,42,0.1); }
html[data-ui-theme-mode="light"] .pane-tab.active { color: #1d4ed8; }

/* 모바일/태블릿: 터미널은 전체 화면으로 밀려 들어오는 패널 */
@media (max-width: 1023.98px) {
    #termPane {
        position: fixed; left: 0; right: 0; top: var(--vv-top); height: var(--app-h);
        z-index: 60; background: var(--shell-bg);
        transform: translateX(100%); visibility: hidden;
        transition: transform 240ms cubic-bezier(.2,.8,.2,1), visibility 0s linear 240ms;
    }
    body.term-open #termPane { transform: none; visibility: visible; transition: transform 240ms cubic-bezier(.2,.8,.2,1); }
    .safe-top-term { padding-top: env(safe-area-inset-top) !important; }
    #termPane .term-head.glass, #termPane .composer.glass { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) { #termPane { transition: none !important; } }

.terminal { -webkit-overflow-scrolling: touch; }
.term-screen {
    font-family: 'JetBrains Mono', ui-monospace, 'D2Coding', 'Nanum Gothic Coding', monospace;
    font-size: var(--term-font); line-height: 1.38;
    padding: 12px 12px 16px; color: #d4d8e1;
    font-variant-ligatures: none;
}
.term-inner { min-width: 100%; }
.term-screen .ln { white-space: pre; min-height: 1.38em; }
.term-screen.wrap .ln { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-all; }
.term-screen.raw .term-inner, .term-screen.fit .term-inner { width: max-content; }
.term-screen .t-rule { height: 1px; margin: 0.6em 0; background: linear-gradient(90deg, rgba(148,163,184,0.28), rgba(148,163,184,0.08)); }
.term-screen .cur { background: #e2e8f0; color: #05070c; border-radius: 1px; animation: tdxCursor 1.1s steps(1) infinite; }
@keyframes tdxCursor { 50% { background: transparent; color: inherit; } }
.term-screen b, .term-screen .b { font-weight: 700; }
.term-screen ::selection { background: rgba(59,130,246,0.35); }
.term-empty-note { color: #64748b; font-style: italic; }

#loadMoreBtn:not(.hidden) {
    display: block; margin: 0 auto 8px; padding: 6px 14px; border-radius: 999px;
    font-size: 11px; font-weight: 700; color: #94a3b8; border: 1px solid rgba(255,255,255,0.08);
}
.jump-bottom {
    position: absolute; right: 14px; bottom: 12px; z-index: 5;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 999px; font-size: 12px; font-weight: 800;
    color: #fff; background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    box-shadow: 0 8px 24px rgba(59,130,246,0.35);
}
.jump-bottom.hidden { display: none; }

/* ── 입력부 ──────────────────────────────────────────────────────── */
.key-chip {
    flex-shrink: 0; min-width: 42px; height: 34px; padding: 0 11px; border-radius: 10px;
    font-family: 'JetBrains Mono', monospace; font-size: 12.5px; font-weight: 700;
    color: rgba(255,255,255,0.75); background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10); transition: background 100ms, transform 100ms;
}
.key-chip:active { transform: scale(0.94); background: rgba(59,130,246,0.25); }
.key-chip.key-accent { color: #93c5fd; border-color: rgba(96,165,250,0.3); }
.key-chip.key-danger { color: #fca5a5; border-color: rgba(248,113,113,0.3); }
html[data-ui-theme-mode="light"] .key-chip { color: #253046; background: rgba(15,23,42,0.05); border-color: rgba(15,23,42,0.12); }
html[data-ui-theme-mode="light"] .key-chip.key-accent { color: #1d4ed8; }
html[data-ui-theme-mode="light"] .key-chip.key-danger { color: #dc2626; }

.composer-btn {
    width: 42px; height: 42px; flex-shrink: 0; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.6); background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.10);
    transition: background 150ms, color 150ms;
}
.composer-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.composer-btn[aria-pressed="true"] { color: #fff; background: linear-gradient(135deg, #f59e0b, #ef4444); border-color: transparent; }
html[data-ui-theme-mode="light"] .composer-btn { color: #47536e; background: rgba(15,23,42,0.05); border-color: rgba(15,23,42,0.12); }
html[data-ui-theme-mode="light"] .composer-btn[aria-pressed="true"] { color: #fff; }
.send-btn { width: 42px; height: 42px; flex-shrink: 0; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.send-btn:disabled { opacity: 0.5; }
/* 16px 이상이어야 iOS 가 입력창 포커스 때 화면을 확대하지 않는다 */
.prompt-input { font-size: 16px; line-height: 1.4; max-height: 38vh; min-height: 42px; display: block; }
@media (min-width: 1024px) { .prompt-input { font-size: 14px; } }
.submit-toggle { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; }
.submit-toggle[aria-pressed="true"] { color: #34d399; }
html[data-ui-theme-mode="light"] .submit-toggle[aria-pressed="true"] { color: #059669; }

/* 직접 입력 모드: 화면 밖에 있지만 포커스 가능한 입력 받개 */
.direct-input { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; font-size: 16px; pointer-events: none; }
body.direct-mode #promptInput { display: none; }
body.direct-mode .direct-banner { display: flex; }
.direct-banner {
    display: none; align-items: center; justify-content: center; gap: 8px; height: 42px;
    border-radius: 14px; font-size: 13px; font-weight: 700;
    color: #fbbf24; background: rgba(245,158,11,0.10); border: 1px dashed rgba(245,158,11,0.45);
}
html[data-ui-theme-mode="light"] .direct-banner { color: #b45309; }

/* ── 시트 / 모달 ─────────────────────────────────────────────────── */
.sheet-overlay {
    position: fixed; inset: 0; z-index: 400;
    background: rgba(5, 7, 15, 0.55);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    display: flex; align-items: flex-end; justify-content: center;
}
.sheet-overlay[hidden] { display: none; }
.tdx-sheet {
    width: 100%; max-height: calc(var(--app-h) - 40px); overflow-y: auto; overscroll-behavior: contain;
    border-radius: 22px 22px 0 0;
    background: rgba(20, 25, 40, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12); border-bottom: 0;
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
    color: #e8e9ee;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}
html[data-ui-theme-mode="light"] .tdx-sheet { background: rgba(255,255,255,0.97); border-color: rgba(15,23,42,0.1); color: #1e2233; box-shadow: 0 -20px 60px rgba(30,41,59,0.2); }
.sheet-grip { width: 38px; height: 4px; border-radius: 99px; background: rgba(148,163,184,0.4); margin: 8px auto 4px; }
@media (min-width: 640px) {
    .sheet-overlay { align-items: center; padding: 20px; }
    .tdx-sheet { max-width: 420px; border-radius: 18px; border-bottom: 1px solid rgba(255,255,255,0.12); padding-bottom: 12px; }
    .sheet-grip { display: none; }
}
.sheet-head { padding: 12px 20px 8px; }
.sheet-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.sheet-head p { margin: 3px 0 0; font-size: 11.5px; opacity: 0.6; line-height: 1.5; word-break: break-all; }
.sheet-actions { padding: 4px 8px; }
.sheet-action {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px;
    padding: 10px 12px; border-radius: 12px; text-align: left;
    font-size: 14px; font-weight: 600; color: inherit;
}
.sheet-action:hover, .sheet-action:focus-visible { background: rgba(148,163,184,0.12); outline: none; }
.sheet-action i.lead { width: 20px; text-align: center; opacity: 0.7; }
.sheet-action .sub { margin-left: auto; font-size: 11px; opacity: 0.5; font-weight: 500; }
.sheet-action.danger { color: #f87171; }
html[data-ui-theme-mode="light"] .sheet-action.danger { color: #dc2626; }
.sheet-action.current { color: #60a5fa; }
.sheet-sep { height: 1px; margin: 4px 12px; background: rgba(148,163,184,0.18); }
.sheet-form { padding: 4px 20px 8px; display: grid; gap: 12px; }
.sheet-form label { display: grid; gap: 6px; font-size: 11px; font-weight: 700; opacity: 0.75; }
.sheet-form input, .sheet-form textarea {
    width: 100%; padding: 10px 12px; border-radius: 12px; font-size: 16px; font-weight: 500;
    color: inherit; background: rgba(148,163,184,0.10); border: 1px solid rgba(148,163,184,0.25);
}
.sheet-form input:focus, .sheet-form textarea:focus { outline: none; border-color: rgba(96,165,250,0.7); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.sheet-buttons { display: flex; gap: 8px; padding: 8px 20px 4px; }
.sheet-buttons button { flex: 1; min-height: 44px; border-radius: 12px; font-size: 14px; font-weight: 800; }
.sheet-cancel { background: rgba(148,163,184,0.14); }
.sheet-danger { color: #fff; background: linear-gradient(135deg, #ef4444, #dc2626); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(148,163,184,0.10); }
.seg button { min-height: 36px; border-radius: 9px; font-size: 12.5px; font-weight: 700; opacity: 0.7; }
.seg button.on { opacity: 1; background: rgba(59,130,246,0.2); color: #93c5fd; }
html[data-ui-theme-mode="light"] .seg button.on { color: #1d4ed8; }
.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.color-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; }
.color-swatch.on { border-color: currentColor; box-shadow: 0 0 0 2px rgba(148,163,184,0.5); }
.snippet-row { display: flex; align-items: center; gap: 4px; }
.snippet-row .sheet-action { flex: 1; min-width: 0; }
.snippet-row .sheet-action span.txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; min-width: 0; }
.snippet-del { width: 40px; height: 40px; border-radius: 10px; opacity: 0.45; flex-shrink: 0; }
.snippet-del:hover { opacity: 1; color: #f87171; }

/* ── 토스트 ──────────────────────────────────────────────────────── */
.toast-host {
    position: fixed; left: 50%; transform: translateX(-50%); z-index: 600;
    top: max(12px, env(safe-area-inset-top)); display: grid; gap: 8px; width: min(92vw, 380px); pointer-events: none;
}
.toast {
    pointer-events: auto; display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; border-radius: 14px; font-size: 13px; font-weight: 600;
    background: rgba(20,25,40,0.95); color: #e8e9ee; border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 12px 30px rgba(0,0,0,0.4); animation: scaleUp 0.18s ease-out;
}
html[data-ui-theme-mode="light"] .toast { background: rgba(255,255,255,0.98); color: #1e2233; border-color: rgba(15,23,42,0.1); box-shadow: 0 12px 30px rgba(30,41,59,0.18); }
.toast.error i { color: #f87171; } .toast.ok i { color: #34d399; } .toast.info i { color: #60a5fa; } .toast.warn i { color: #fbbf24; }
.toast button { margin-left: auto; font-size: 12px; font-weight: 800; color: #60a5fa; white-space: nowrap; }

/* ── 창 정리 페이지 ─────────────────────────────────────────────── */
.org-folder .org-list { min-height: 48px; }
.org-list:empty::after {
    content: "여기로 창을 끌어다 놓으세요"; display: block; padding: 14px; text-align: center;
    font-size: 11px; color: rgba(148,163,184,0.7); border: 1px dashed rgba(148,163,184,0.3); border-radius: 12px;
}
.org-item { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 4px; border-radius: 12px; min-height: 54px; }
.org-item:hover { background: rgba(255,255,255,0.04); }
html[data-ui-theme-mode="light"] .org-item:hover { background: rgba(15,23,42,0.03); }
.org-item.is-hidden .org-main { opacity: 0.45; }
.drag-handle {
    width: 34px; height: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    color: rgba(148,163,184,0.7); cursor: grab; touch-action: none; border-radius: 8px;
}
.drag-handle:active { cursor: grabbing; }
.org-icon-btn {
    width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; color: rgba(148,163,184,0.9);
}
.org-icon-btn:hover { background: rgba(148,163,184,0.14); }
.org-icon-btn.on { color: #fbbf24; }
.sortable-ghost { opacity: 0.35; background: rgba(59,130,246,0.15) !important; border-radius: 12px; }
.sortable-chosen { background: rgba(59,130,246,0.08); }
.sortable-drag { opacity: 0.95 !important; }

/* ── 첨부 ────────────────────────────────────────────────────────── */
.attach-btn {
    position: absolute; right: 4px; bottom: 3px; width: 36px; height: 36px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.5); transition: background 150ms, color 150ms;
}
.attach-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
html[data-ui-theme-mode="light"] .attach-btn { color: #5a6781; }
html[data-ui-theme-mode="light"] .attach-btn:hover { background: rgba(15,23,42,0.06); color: #101828; }
body.direct-mode .attach-btn { display: none; }
.attach-tray:not(.hidden) { display: flex; }
.attach-chip {
    position: relative; flex-shrink: 0; display: flex; align-items: center; gap: 8px;
    max-width: 220px; height: 52px; padding: 5px 30px 5px 5px; border-radius: 14px; overflow: hidden;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.10);
}
html[data-ui-theme-mode="light"] .attach-chip { background: rgba(15,23,42,0.04); border-color: rgba(15,23,42,0.12); }
.attach-chip.error { border-color: rgba(248,113,113,0.5); background: rgba(239,68,68,0.08); }
.attach-thumb {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; object-fit: cover;
    display: flex; align-items: center; justify-content: center; font-size: 16px;
    background: rgba(148,163,184,0.15); color: #94a3b8;
}
.attach-meta { min-width: 0; display: grid; gap: 1px; }
.attach-name { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-sub { font-size: 10px; opacity: 0.55; font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
.attach-chip.error .attach-sub { color: #f87171; opacity: 1; }
.attach-progress { position: absolute; left: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, #3b82f6, #8b5cf6); transition: width 150ms; }
.attach-remove {
    position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; font-size: 11px; opacity: 0.6;
}
.attach-remove:hover { opacity: 1; background: rgba(148,163,184,0.2); }
.drop-overlay {
    position: absolute; inset: 10px; z-index: 30; border-radius: 20px;
    display: flex; align-items: center; justify-content: center; text-align: center;
    border: 2px dashed rgba(96,165,250,0.8); background: rgba(15,23,42,0.72);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: #bfdbfe; pointer-events: none;
}
.drop-overlay.hidden { display: none; }
.drop-card { padding: 24px; }
.win-item.drop-target { background: rgba(59,130,246,0.2); border-color: rgba(96,165,250,0.6); border-style: dashed; }

/* ── 정렬 버튼 ───────────────────────────────────────────────────── */
.sort-btn {
    flex-shrink: 0; height: 38px; padding: 0 12px; border-radius: 12px;
    display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; white-space: nowrap;
    color: rgba(255,255,255,0.65); background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12);
    transition: background 150ms, color 150ms;
}
.sort-btn:hover { background: rgba(255,255,255,0.09); color: #fff; }
html[data-ui-theme-mode="light"] .sort-btn { color: #47536e; background: rgba(255,255,255,0.7); border-color: rgba(15,23,42,0.12); }
html[data-ui-theme-mode="light"] .sort-btn:hover { background: rgba(15,23,42,0.06); color: #101828; }

/* ── 화면 / 대화 기록 전환 ───────────────────────────────────────── */
#termModes:not(.hidden) { display: flex; }
.mode-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(148,163,184,0.12); flex-shrink: 0; }
.mode-switch button { padding: 5px 12px; border-radius: 8px; font-size: 12px; font-weight: 700; color: rgba(255,255,255,0.55); white-space: nowrap; }
.mode-switch button i { font-size: 10px; margin-right: 3px; }
.mode-switch button.on { background: rgba(59,130,246,0.22); color: #bfdbfe; }
html[data-ui-theme-mode="light"] .mode-switch button { color: #5a6781; }
html[data-ui-theme-mode="light"] .mode-switch button.on { background: rgba(59,130,246,0.14); color: #1d4ed8; }

.alt-hint {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; padding: 8px 12px; border-radius: 10px;
    font-family: 'Inter', system-ui, sans-serif; font-size: 12px; color: #93c5fd;
    background: rgba(59,130,246,0.10); border: 1px solid rgba(96,165,250,0.25); white-space: normal;
}
.alt-hint button { font-weight: 800; color: #fff; padding: 3px 10px; border-radius: 8px; background: rgba(59,130,246,0.45); }

/* ── 대화 기록 (터미널 영역 안이라 항상 어두운 배경) ─────────────── */
.chat-list { padding: 12px 12px 20px; display: flex; flex-direction: column; gap: 10px; font-family: 'Inter', 'Pretendard', system-ui, sans-serif; color: #dbe1ea; }
.log-older { text-align: center; padding: 10px; font-size: 11px; color: #64748b; font-family: 'Inter', system-ui, sans-serif; }
.log-older button { font-weight: 700; color: #93c5fd; }
.log-empty { padding: 40px 16px; text-align: center; color: #64748b; font-size: 13px; line-height: 1.6; }
.msg { max-width: 100%; min-width: 0; }
.msg-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 10.5px; font-weight: 700; color: #64748b; }
.msg-body { font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.msg-user { align-self: flex-end; max-width: 88%; }
.msg-user .msg-meta { justify-content: flex-end; }
.msg-user .msg-body { padding: 9px 13px; border-radius: 16px 16px 4px 16px; background: rgba(59,130,246,0.22); border: 1px solid rgba(96,165,250,0.28); color: #eaf2ff; }
.msg-ai .msg-body { padding: 2px 2px; }
.msg-ai .copy-btn { margin-left: auto; padding: 2px 6px; border-radius: 6px; color: #64748b; font-size: 11px; }
.msg-ai .copy-btn:hover { color: #cbd5e1; background: rgba(255,255,255,0.06); }
.msg-system { align-self: center; font-size: 11px; font-weight: 700; color: #94a3b8; padding: 3px 10px; border-radius: 999px; background: rgba(148,163,184,0.12); font-family: 'JetBrains Mono', monospace; }
.md-code { margin: 6px 0; padding: 10px 12px; border-radius: 10px; background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.06); overflow-x: auto; white-space: pre; font-family: 'JetBrains Mono', monospace; font-size: 12px; line-height: 1.5; color: #cbd5e1; }
.msg-body code { font-family: 'JetBrains Mono', monospace; font-size: 0.88em; padding: 1px 5px; border-radius: 5px; background: rgba(148,163,184,0.16); color: #fcd34d; }
.md-h { font-weight: 800; color: #fff; }
.msg-tool { border-radius: 10px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); font-size: 12px; }
.msg-tool summary { display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer; list-style: none; min-width: 0; }
.msg-tool summary::-webkit-details-marker { display: none; }
.msg-tool summary .tool-name { flex-shrink: 0; font-weight: 800; color: #a5b4fc; font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.msg-tool summary .tool-sum { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #94a3b8; font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.msg-tool summary .tool-state { flex-shrink: 0; font-size: 10px; color: #34d399; }
.msg-tool.error summary .tool-state { color: #f87171; }
.msg-tool.error { border-color: rgba(248,113,113,0.25); }
.msg-tool pre { margin: 0; padding: 8px 10px 10px; border-top: 1px solid rgba(255,255,255,0.06); max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-family: 'JetBrains Mono', monospace; font-size: 11px; line-height: 1.5; color: #a8b3c4; }

/* 시트 폼 안의 체크박스 줄 */
.sheet-form label.check-row { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; opacity: 0.9; }
.sheet-form input[type="checkbox"] { width: 18px; height: 18px; padding: 0; flex-shrink: 0; accent-color: #8b5cf6; }

/* ============================================================================
   휴대폰에서 앱처럼 — 확대 막기, 키보드 대응, 하단 탭바, 터치 반응
   ============================================================================ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }

/* 앱 전체를 실제로 보이는 영역(visualViewport)에 고정한다.
   iOS 는 키보드가 올라오면 레이아웃은 그대로 두고 보이는 영역만 밀어 올리는데(offsetTop),
   그 움직임을 따라가야 화면이 잘리거나 아래에 빈 공간이 생기지 않는다. */
html:has(body.app-shell) { height: 100%; overflow: hidden; }
body.app-shell {
    position: fixed; left: 0; right: 0; top: var(--vv-top);
    height: var(--app-h); width: 100%; overflow: hidden;
}

@media (pointer: coarse), (max-width: 767.98px) {
    /* 16px 미만 입력창은 iOS 가 포커스할 때 화면을 확대한다 */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), textarea, select { font-size: 16px !important; }

    /* 버튼 · 메뉴는 길게 눌러도 글자 선택 · 미리보기가 뜨지 않게 (내용 영역은 그대로 선택 가능) */
    body.app-shell { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
    body.app-shell :is(input, textarea, pre, code, table, .term-screen, .chat-list, .git-diff, .msg-body, .select-text, #gitConsole) {
        -webkit-user-select: text; user-select: text; -webkit-touch-callout: default;
    }
    ::-webkit-scrollbar { width: 0; height: 0; }
    .overflow-y-auto, .overflow-auto, .overflow-x-auto { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

    /* 누르는 느낌 */
    button:active, .tab-item:active, .filter-chip:active, .sheet-action:active { opacity: 0.65; }
}

/* 하단 탭바 */
.tabbar {
    display: flex; flex-shrink: 0; z-index: 30;
    /* 홈 인디케이터와 살짝 겹치게 해서 네이티브 탭바처럼 낮게 (전체 inset 을 다 쓰면 아래가 붕 뜬다) */
    padding: 6px 6px max(6px, calc(env(safe-area-inset-bottom) - 12px));
    background: rgba(10, 13, 24, 0.92);
    backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
html[data-ui-theme-mode="light"] .tabbar { background: rgba(255, 255, 255, 0.92); border-top-color: rgba(15, 23, 42, 0.08); }
.tab-item {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 5px 0 2px; border-radius: 12px; color: rgba(255, 255, 255, 0.45);
    -webkit-tap-highlight-color: transparent;
}
.tab-item .tab-icon { position: relative; font-size: 18px; line-height: 1; height: 20px; }
.tab-item .tab-label { font-size: 10.5px; font-weight: 700; letter-spacing: -0.01em; }
.tab-item.active { color: #93c5fd; }
html[data-ui-theme-mode="light"] .tab-item { color: #8a92aa; }
html[data-ui-theme-mode="light"] .tab-item.active { color: #2563eb; }
.tab-badge {
    position: absolute; top: -5px; left: 13px; min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px; background: #f59e0b; color: #111827; font-size: 10px; font-weight: 800;
    display: flex; align-items: center; justify-content: center; font-family: 'Inter', system-ui, sans-serif;
}
.tab-badge.hidden { display: none; }
/* 키보드가 올라와 있으면 탭바를 숨겨 입력 공간을 확보한다 */
html.kb-open .tabbar { display: none; }
@media (max-width: 767.98px) {
    /* 탭바가 홈 인디케이터 영역을 맡으므로 본문 스크롤 영역은 그만큼 띄우지 않는다 */
    main .safe-bottom:not(.composer) { padding-bottom: 0.75rem !important; }
}
/* 키보드가 덮고 있으니 입력창 아래 안전 영역 여백은 필요 없다 */
html.kb-open .composer.safe-bottom { padding-bottom: 0.25rem !important; }
