* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0a1420;
    --surface: #122030;
    --surface-light: #1a2c40;
    --accent: #21a8a2;
    --accent-soft: #4dcdc6;
    --secondary: #e6c789;
    --text: #e8eef5;
    --text-dim: #8c9bad;
    --bot-bg: #142030;
    --user-bg: #21a8a2;
    --input-bg: #0e1822;
    --border: #1e2e44;
    --success: #4ad97a;
    --danger: #ec5f72;
    --warning: #f5b042;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    inset: 0;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 880px;
    margin: 0 auto;
}

.header {
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.logo-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.logo-icon { font-size: 32px; }
.logo-text h1 { font-size: 19px; font-weight: 700; color: var(--secondary); }
.subtitle { font-size: 13px; color: var(--text-dim); }
.header-nav { display: flex; gap: 14px; }
.nav-link { color: var(--text-dim); text-decoration: none; font-size: 14px; }
.nav-link.active { color: var(--accent-soft); }

.chat {
    flex: 1; min-height: 0; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    display: flex; flex-direction: column; gap: 14px;
}

.message {
    display: flex; gap: 10px; max-width: 100%;
    animation: fadeIn 0.3s ease;
}
.message.bot { align-self: flex-start; }
.message-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--surface-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.message-content {
    background: var(--bot-bg); padding: 12px 16px;
    border-radius: 14px 14px 14px 4px;
    line-height: 1.5; max-width: 100%; min-width: 0;
}
.message-content p { margin-bottom: 8px; }
.message-content p:last-child { margin-bottom: 0; }

.example-queries { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.example-btn {
    background: var(--surface-light); color: var(--accent-soft);
    border: 1px solid var(--border);
    padding: 6px 12px; border-radius: 14px;
    cursor: pointer; font-size: 13px;
}
.example-btn:hover { background: var(--accent); color: white; }

/* Input area */
.input-area {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    display: flex; flex-direction: column; gap: 10px;
    flex-shrink: 0;
}
.input-area textarea {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 14px;
    font: inherit;
    resize: vertical; min-height: 48px;
}
.input-area textarea:focus { outline: none; border-color: var(--accent); }

.controls {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    justify-content: space-between;
}
.tld-fieldset {
    border: 1px solid var(--border); border-radius: 8px;
    padding: 6px 10px; min-width: 0; flex: 1 1 280px;
}
.tld-fieldset legend { color: var(--text-dim); font-size: 12px; padding: 0 4px; }
.tld-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tld-list label {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 999px;
    background: var(--surface-light);
    cursor: pointer; font-size: 13px; user-select: none;
}
.tld-list input[type=checkbox] { accent-color: var(--accent); margin-right: 2px; }
.tld-list label:has(input:checked) { background: var(--accent); color: white; }
.count-label {
    color: var(--text-dim); font-size: 13px;
    display: flex; align-items: center; gap: 6px;
    flex-shrink: 0;
}
.count-label input[type=range] { accent-color: var(--accent); width: 110px; }
#sendBtn {
    background: var(--accent); color: white;
    border: none; padding: 10px 18px;
    border-radius: 10px; font-weight: 600;
    cursor: pointer; font-size: 14px;
    flex-shrink: 0;
}
#sendBtn:hover { background: var(--accent-soft); }
#sendBtn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Result table */
.result-table {
    width: 100%; border-collapse: collapse; margin-top: 8px;
    background: var(--bg); border-radius: 8px; overflow: hidden;
}
.result-table th, .result-table td {
    padding: 8px 10px; text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.result-table th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.result-table tr.free td { color: var(--text); }
.result-table tr.taken td { color: var(--text-dim); }
.result-table tr.unknown td { color: var(--warning); }
.status-badge {
    display: inline-block; padding: 2px 8px;
    border-radius: 999px; font-size: 12px; font-weight: 600;
}
.status-badge.free { background: rgba(74, 217, 122, 0.18); color: var(--success); }
.status-badge.taken { background: rgba(236, 95, 114, 0.16); color: var(--danger); }
.status-badge.unknown { background: rgba(245, 176, 66, 0.18); color: var(--warning); }
.score-pill {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    background: var(--surface-light); color: var(--accent-soft);
    font-size: 12px; font-weight: 600;
}
.domain-cell { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.domain-cell a { color: var(--accent-soft); text-decoration: none; }
.domain-cell a:hover { text-decoration: underline; }
.reasoning-cell { color: var(--text-dim); font-size: 13px; max-width: 280px; }

.stats-row {
    display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0 4px;
    color: var(--text-dim); font-size: 13px;
}
.stats-row .stat { background: var(--surface-light); padding: 4px 10px; border-radius: 999px; }
.stats-row .stat .num { color: var(--text); font-weight: 600; }

.share-link {
    margin-top: 10px; font-size: 13px; color: var(--text-dim);
    word-break: break-all;
}
.share-link a { color: var(--accent-soft); }

.recent-section { padding: 16px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }
.recent-section h2 { font-size: 15px; color: var(--text-dim); margin-bottom: 8px; }
.recent-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.recent-item { padding: 6px 10px; border-radius: 6px; background: var(--surface); cursor: pointer; }
.recent-item:hover { background: var(--surface-light); }
.recent-item .desc { font-size: 13px; }
.recent-item .meta { font-size: 11px; color: var(--text-dim); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 600px) {
    .header { padding: 10px 14px; }
    .logo-icon { font-size: 28px; }
    .logo-text h1 { font-size: 17px; }
    .subtitle { display: none; }
    .chat { padding: 14px; }
    .input-area { padding: 10px 14px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .controls { flex-direction: column; align-items: stretch; gap: 10px; }
    .count-label { justify-content: space-between; }
    .count-label input[type=range] { flex: 1; max-width: none; }
    #sendBtn { width: 100%; padding: 14px; font-size: 16px; }
    .result-table th, .result-table td { padding: 6px 8px; font-size: 13px; }
    .reasoning-cell { max-width: none; }
}
