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

/* ── Root ───────────────────────────────────────────────────── */
:root {
    --bg:          #fdfbf7;
    --bg-sub:      #f5f0e8;
    --bg3:         #ede6d6;
    --border:      #d4c4a8;
    --text:        #2c1a0e;
    --muted:       #6b4c35;
    --accent:      #c8621a;
    --primary:     #8b2252;
    --primary-dark:#6b1a3f;
    --success:     #2e7d32;
    --error:       #c33;
    --info:        #1565c0;
}

body {
    font-family: 'Noto Sans Kannada', 'Tiro Kannada', system-ui, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    height: 100vh;
    overflow: hidden;
}

/* ── App shell ──────────────────────────────────────────────── */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1280px;
    margin: 0 auto;
}

/* ── Header ─────────────────────────────────────────────────── */
header {
    display: flex;
    align-items: center;
    height: 46px;
    padding: 0 16px;
    background: linear-gradient(135deg, #3d1a08 0%, #6b1a3f 100%);
    flex-shrink: 0;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
}

.logo {
    width: 26px;
    height: 26px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.subtitle {
    font-size: 12px;
    color: rgba(255,255,255,0.60);
}

/* ── Tab nav ─────────────────────────────────────────────────── */
nav.tabs {
    display: flex;
}

.tab-button {
    height: 46px;
    padding: 0 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: rgba(255,255,255,0.55);
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
    font-family: inherit;
}

.tab-button:hover  { color: rgba(255,255,255,0.9); }
.tab-button.active { color: #fff; border-bottom-color: var(--accent); font-weight: 600; }

/* ── Status bars ─────────────────────────────────────────────── */
.status-bar {
    padding: 5px 16px;
    font-size: 12px;
    flex-shrink: 0;
    border-bottom: 1px solid transparent;
}
.status-bar.progress { background: #e3f2fd; color: var(--info);    border-color: #c5e0f8; }
.status-bar.error    { background: #ffebee; color: var(--error);   border-color: #f5c6cb; }
.status-bar.success  { background: #e8f5e9; color: var(--success); border-color: #c3e6cb; }

/* ── Tab content ─────────────────────────────────────────────── */
.tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.tab-content.active { display: flex; }

/* ── Toolbar ─────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
    background: var(--bg-sub);
}

/* ── Info bar ───────────────────────────────────────────────── */
.info-bar {
    padding: 4px 12px;
    font-size: 12px;
    color: var(--muted);
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-bar.detect { background: #e8f5e9; border-bottom-color: #c3e6cb; color: #2d6a32; }
.info-bar .sep   { margin: 0 5px; color: var(--border); }
.info-bar .muted { color: var(--muted); }

/* ── Panels ──────────────────────────────────────────────────── */
.panels {
    display: flex;
    flex: 1;
    min-height: 0;
}

.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-right: 1px solid var(--border);
}

.panel:last-child { border-right: none; }

.panel-head {
    padding: 5px 12px;
    font-size: 12px;
    color: var(--muted);
    background: var(--bg-sub);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel textarea {
    flex: 1;
    width: 100%;
    border: none;
    padding: 12px 14px;
    font-family: 'Noto Sans Kannada', 'Tiro Kannada', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.7;
    resize: none;
    outline: none;
    color: var(--text);
    background: var(--bg);
}

.panel textarea:focus { background: #fffef9; }

/* File/conversion panels */
#filePreviewSection,
#conversionResults,
#textOutput {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}
#conversionResults:last-child,
#textOutput:last-child { border-right: none; }

/* ── Char count ──────────────────────────────────────────────── */
.cc {
    font-size: 11px;
    color: var(--border);
    margin-left: 4px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background .12s, border-color .12s;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover  { background: var(--bg-sub); border-color: var(--muted); }
.btn:active { background: var(--bg3); }

.btn-primary       { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success       { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #1b5e20; border-color: #1b5e20; }

.file-btn { cursor: pointer; }
.file-btn input[type=file] { display: none; }

/* ── Selects ─────────────────────────────────────────────────── */
.sel {
    padding: 5px 28px 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b4c35' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 14px;
}

.sel:focus { outline: none; border-color: var(--accent); }

/* ── Checkbox ────────────────────────────────────────────────── */
.chk {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    color: var(--text);
}

/* ── Format badges ───────────────────────────────────────────── */
.format-badge         { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px; font-weight: 600; }
.format-badge.unicode { background: #e8f5e9; color: var(--success); }
.format-badge.ascii   { background: var(--bg3); color: var(--muted); }

/* ── Detection tab ───────────────────────────────────────────── */
.det-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.det-summary {
    display: flex;
    gap: 20px;
    font-size: 13px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.stray-list { font-size: 13px; }

.stray-char-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--bg3);
}

.stray-char-item:last-child { border-bottom: none; }

.stray-char-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.stray-char-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.stray-char-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #ffebee;
    color: var(--error);
    border-radius: 3px;
    font-family: monospace;
    font-size: 12px;
    font-weight: 600;
}

.stray-location { font-size: 11px; color: var(--muted); }
.stray-type     { font-size: 11px; color: var(--accent); font-style: italic; }

.stray-context {
    background: var(--bg-sub);
    padding: 5px 10px;
    border-left: 2px solid var(--error);
    font-family: monospace;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.stray-context-highlight {
    background: rgba(204,51,51,.15);
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 700;
    color: var(--error);
}

.no-stray-message {
    padding: 16px;
    text-align: center;
    color: var(--success);
    font-size: 13px;
    background: #e8f5e9;
    border-radius: 4px;
    border: 1px solid #c3e6cb;
}

/* ── Help tab ────────────────────────────────────────────────── */
.help-wrap {
    display: flex;
    gap: 40px;
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.help-col { flex: 1; }

.help-col h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin: 20px 0 8px;
}

.help-col h3:first-child { margin-top: 0; }

.help-col ul, .help-col ol {
    padding-left: 18px;
    margin-bottom: 8px;
}

.help-col li {
    margin-bottom: 4px;
    line-height: 1.6;
    color: var(--text);
}

.help-col p { font-size: 13px; color: var(--text); margin-bottom: 6px; }

.help-footer { margin-top: 32px; color: var(--border); font-size: 12px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
    body { overflow: auto; }
    .app { height: auto; min-height: 100vh; }
    .panels { flex-direction: column; }
    .panel textarea { min-height: 200px; }
    .help-wrap { flex-direction: column; gap: 0; }
    .subtitle { display: none; }
}
