:root {
    --bg: #eef1f4;
    --bg-accent: #f7f8fa;
    --card: #ffffff;
    --card-soft: #f8fafb;
    --text: #1e2933;
    --muted: #61707d;
    --line: #d7dde3;
    --line-strong: #c3cbd3;
    --primary: #36566d;
    --primary-dark: #2a4355;
    --secondary: #dce4ea;
    --secondary-dark: #cbd5dd;
    --danger: #b45858;
    --danger-dark: #984545;
    --shadow: 0 16px 34px rgba(31, 42, 51, 0.08);
    --radius: 20px;
    --radius-small: 14px;
    --font-main: "Segoe UI Variable", "Trebuchet MS", "Noto Sans", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-main);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.88), transparent 35%),
        linear-gradient(180deg, #f5f7f9 0%, var(--bg) 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(120deg, rgba(54, 86, 109, 0.03), transparent 50%),
        linear-gradient(320deg, rgba(54, 86, 109, 0.025), transparent 50%);
}

.page-shell {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 20px 14px 34px;
    position: relative;
}

.login-body .page-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.card,
.card-soft {
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-soft {
    background: var(--card-soft);
    box-shadow: none;
    border-color: var(--line);
    border-radius: var(--radius-small);
}

.app-card,
.archive-card,
.login-card {
    padding: 18px;
}

.login-card {
    width: min(100%, 460px);
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.eyebrow {
    margin: 0 0 4px;
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

h1,
h2 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(1.5rem, 4vw, 2rem);
}

h2 {
    font-size: 1rem;
}

.subtle-text,
.login-footnote,
.result-count {
    color: var(--muted);
}

.subtle-text,
.login-footnote {
    margin: 0;
    line-height: 1.5;
}

.result-count {
    margin: 10px 0 14px;
    font-size: 0.95rem;
}

.status-bar {
    margin: 12px 0 14px;
    padding: 12px 14px;
    border-radius: 999px;
    background: #edf4f8;
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 0.96rem;
    border: 1px solid rgba(54, 86, 109, 0.12);
}

.recording-panel,
.action-grid,
.archive-actions {
    display: grid;
    gap: 10px;
}

.recording-panel {
    grid-template-columns: 1.4fr 1fr;
    margin: 16px 0;
}

.action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 16px 0 18px;
}

.archive-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 16px;
}

.field {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.field span {
    font-weight: 600;
    font-size: 0.95rem;
}

input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    font: inherit;
    color: var(--text);
    background: #fbfcfd;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
    resize: vertical;
    min-height: 170px;
    line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(54, 86, 109, 0.55);
    box-shadow: 0 0 0 4px rgba(54, 86, 109, 0.09);
    background: #ffffff;
}

.button {
    appearance: none;
    border: 0;
    border-radius: 16px;
    padding: 12px 15px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.button:hover,
.button:focus-visible {
    transform: translateY(-1px);
}

.button:disabled {
    opacity: 0.58;
    cursor: not-allowed;
    transform: none;
}

.button-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 10px 20px rgba(54, 86, 109, 0.18);
}

.button-primary:hover,
.button-primary:focus-visible {
    background: var(--primary-dark);
}

.button-secondary {
    background: var(--secondary);
    color: var(--text);
}

.button-secondary:hover,
.button-secondary:focus-visible {
    background: var(--secondary-dark);
}

.button-ghost {
    background: #f7f8fa;
    color: var(--text);
    border: 1px solid var(--line);
}

.button-ghost:hover,
.button-ghost:focus-visible {
    background: #eef2f5;
}

.button-danger {
    background: var(--danger);
    color: #ffffff;
}

.button-danger:hover,
.button-danger:focus-visible {
    background: var(--danger-dark);
}

.button-large {
    min-height: 64px;
    font-size: 1.12rem;
}

.button-small {
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 0.92rem;
}

.button-full {
    width: 100%;
}

.answer-box {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
    padding: 16px;
}

.answer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.answer-meta {
    color: var(--muted);
    font-size: 0.9rem;
}

.answer-content,
.formatted-text {
    white-space: pre-wrap;
    line-height: 1.6;
    word-break: break-word;
}

.notice {
    padding: 12px 14px;
    border-radius: 16px;
    margin: 14px 0 0;
    line-height: 1.45;
}

.notice-error {
    background: #fdeeee;
    color: #8c3b3b;
    border: 1px solid #f0c8c8;
}

.notice-muted {
    background: #f4f6f8;
    color: var(--muted);
    border: 1px solid var(--line);
}

.hidden {
    display: none !important;
}

.stack-form {
    margin-top: 16px;
}

.archive-filters {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text);
}

.archive-list {
    display: grid;
    gap: 12px;
}

.archive-item {
    overflow: hidden;
}

.archive-summary {
    list-style: none;
    cursor: pointer;
    padding: 16px;
}

.archive-summary::-webkit-details-marker {
    display: none;
}

.archive-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e7edf2;
    color: var(--primary-dark);
    font-size: 0.82rem;
    font-weight: 700;
}

.tag-favorite {
    background: #ebe5da;
    color: #756242;
}

.archive-preview {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.archive-body {
    padding: 0 16px 16px;
}

.archive-section + .archive-section {
    margin-top: 16px;
}

.empty-state {
    padding: 22px 18px;
    border: 1px dashed var(--line-strong);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.7);
}

@media (max-width: 640px) {
    .page-shell {
        padding-inline: 12px;
    }

    .app-card,
    .archive-card,
    .login-card {
        padding: 16px;
    }

    .topbar,
    .answer-header {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-actions {
        justify-content: flex-start;
    }

    .recording-panel,
    .action-grid,
    .archive-actions {
        grid-template-columns: 1fr;
    }

    textarea {
        min-height: 190px;
    }
}
