/* ==========================================================================
   Nomi Web — Apple-style Minimal Design
   Mobile-first, responsive, dark mode support.
   No AI icons. No robot imagery. Pure typography + geometry.
   ========================================================================== */

:root {
    --color-bg: #ffffff;
    --color-surface: #f5f5f7;
    --color-text: #1d1d1f;
    --color-text-secondary: #86868b;
    --color-accent: #0071e3;
    --color-accent-hover: #0077ed;
    --color-border: #d2d2d7;
    --color-card: #ffffff;
    --color-card-shadow: rgba(0, 0, 0, 0.06);
    --color-user-bubble: #f0f0f5;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;
    --transition: 200ms ease-out;
    --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #000000;
        --color-surface: #1c1c1e;
        --color-text: #f5f5f7;
        --color-text-secondary: #98989d;
        --color-accent: #0a84ff;
        --color-accent-hover: #409cff;
        --color-border: #38383a;
        --color-card: #1c1c1e;
        --color-card-shadow: rgba(0, 0, 0, 0.3);
        --color-user-bubble: #2c2c2e;
    }
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Landing Page
   ========================================================================== */
.landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    text-align: center;
    animation: fadeIn 600ms ease-out;
}

.landing-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 600px;
}

.landing-icon {
    width: 96px;
    height: 96px;
    border-radius: 20px;
    margin-bottom: 24px;
    animation: fadeIn 800ms ease-out;
}

.landing-title {
    font-size: clamp(1.8rem, 5vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
    color: var(--color-text);
}

.landing-subtitle {
    font-size: clamp(0.95rem, 2vw, 1.2rem);
    color: var(--color-text-secondary);
    margin-bottom: 48px;
    font-weight: 400;
}

.landing-disclaimer {
    font-size: 0.7rem;
    line-height: 1.5;
    color: var(--color-text-secondary);
    opacity: 0.75;
    padding: 0 24px 24px;
    max-width: 560px;
    text-align: center;
}
.landing-disclaimer a {
    color: var(--color-text-secondary);
    text-decoration: underline;
}
.landing-disclaimer a:hover {
    color: var(--color-accent);
}

/* ==========================================================================
   Beta badge — minimal pill, no icons
   ========================================================================== */
.beta-badge {
    display: inline-block;
    vertical-align: middle;
    margin-left: 8px;
    padding: 2px 10px;
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: 999px;
    opacity: 0.85;
    white-space: nowrap;
}
.chat-title .beta-badge {
    font-size: 0.6rem;
    padding: 1px 8px;
}

/* ==========================================================================
   Modal — shared by beta gate + full disclaimer
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.modal-card {
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--color-card);
    border-radius: 18px;
    padding: 28px 26px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.25s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 10px;
}
.modal-text {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--color-text-secondary);
    margin-bottom: 14px;
}
.modal-input {
    width: 100%;
    padding: 11px 14px;
    font-size: 0.95rem;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-surface);
    color: var(--color-text);
    outline: none;
    transition: border-color 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.modal-input:focus {
    border-color: var(--color-accent);
}
.modal-error {
    min-height: 18px;
    font-size: 0.75rem;
    color: #c0392b;
    margin: 6px 0 8px;
}
.modal-btn {
    width: 100%;
    margin-top: 4px;
}

/* ==========================================================================
   Chat footer disclaimer — always visible under the input
   ========================================================================== */
.chat-disclaimer {
    margin-top: 8px;
    font-size: 0.65rem;
    line-height: 1.4;
    text-align: center;
    color: var(--color-text-secondary);
    opacity: 0.75;
}
.chat-disclaimer a {
    color: var(--color-text-secondary);
    text-decoration: underline;
}
.chat-disclaimer a:hover {
    color: var(--color-accent);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn-primary {
    display: inline-block;
    padding: 14px 32px;
    font-size: 1rem;
    font-weight: 500;
    color: #ffffff;
    background: var(--color-accent);
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: transform var(--transition), background var(--transition);
    min-height: 48px;
    min-width: 140px;
}

.btn-primary:hover {
    background: var(--color-accent-hover);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================================================
   Chat Interface
   ========================================================================== */
.chat {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 700px;
    margin: 0 auto;
    animation: fadeIn 300ms ease-out;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.btn-back {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--color-surface);
    border-radius: 50%;
    font-size: 1.1rem;
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition);
}

.btn-back:hover {
    background: var(--color-border);
}

.chat-title {
    font-size: 1rem;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Message cards */
.message {
    max-width: 85%;
    animation: slideUp 200ms ease-out;
}

.message-user {
    align-self: flex-end;
    background: var(--color-user-bubble);
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    border-bottom-right-radius: 4px;
    font-size: 0.95rem;
}

.message-bot-wrapper {
    align-self: flex-start;
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: slideUp 200ms ease-out;
}

.message-bot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
    margin-top: 2px;
}

.message-system {
    align-self: flex-start;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px var(--color-card-shadow);
    font-size: 0.95rem;
    line-height: 1.7;
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

.message-system a {
    color: var(--color-accent);
    text-decoration: none;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.message-system a:hover {
    text-decoration: underline;
}

.message-system p {
    margin-bottom: 8px;
}

.message-system p:last-child {
    margin-bottom: 0;
}

.message-system ul,
.message-system ol {
    padding-left: 20px;
    margin-bottom: 8px;
}

.message-system li {
    margin-bottom: 4px;
}

.message-system strong {
    font-weight: 600;
}

.message-system h1,
.message-system h2,
.message-system h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 12px 0 6px;
}

.message-system h1:first-child,
.message-system h2:first-child,
.message-system h3:first-child {
    margin-top: 0;
}

/* Citations / sources block (appended after the answer body) */
.message-system .sources {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
}

.message-system .sources-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.message-system .sources-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.message-system .sources-list li {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--color-text-secondary);
    margin-bottom: 0;
}

.message-system .sources-list .src-num {
    flex: 0 0 auto;
    color: var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
}

.message-system .sources-list .src-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.message-system .sources-list a {
    color: var(--color-accent);
}

/* ==========================================================================
   Loading indicator — three dots pulse animation
   ========================================================================== */
.loading {
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 16px 20px;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px var(--color-card-shadow);
    animation: slideUp 200ms ease-out;
}

.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-secondary);
    animation: pulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.loading-text {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    transition: opacity var(--transition);
}

/* ==========================================================================
   Clarification / Narrowing — clickable option cards
   ========================================================================== */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.option-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    text-align: left;
    font-size: 0.9rem;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    min-height: 44px;
}

.option-btn:hover {
    background: var(--color-border);
}

.option-btn:active {
    transform: scale(0.98);
}

/* ==========================================================================
   Feedback — ghost thumbs under each answer (quiet until needed)
   ========================================================================== */
.fb-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
    animation: fb-enter 0.4s ease both;
}

.fb-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

@keyframes fb-enter {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fb-prompt {
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    margin-right: 2px;
    transition: opacity var(--transition);
}

.fb-prompt.fb-gone { opacity: 0; display: none; }

.fb-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--color-text);
    background: var(--color-bg, #fff);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--transition), border-color var(--transition),
                background var(--transition), opacity var(--transition),
                transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fb-pill svg { flex: 0 0 auto; opacity: 0.75; }

.fb-pill:hover:not(:disabled) {
    color: var(--color-text);
    border-color: var(--color-text-secondary);
    background: rgba(0, 0, 0, 0.03);
}

.fb-pill:active { transform: scale(0.96); }

/* selected states — quiet color coding, no traffic-light brightness */
.fb-pill.fb-yes.fb-active {
    color: #1d7a3e;
    border-color: rgba(29, 122, 62, 0.4);
    background: rgba(29, 122, 62, 0.07);
}

.fb-pill.fb-no.fb-active {
    color: #9a4238;
    border-color: rgba(154, 66, 56, 0.35);
    background: rgba(154, 66, 56, 0.06);
}

.fb-pill.fb-active { transform: scale(1.02); }
.fb-pill.fb-active svg { opacity: 1; }

.fb-pill.fb-gone {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92);
}

.fb-pill:disabled { cursor: default; }

.fb-note {
    margin-left: 6px;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    animation: fb-enter 0.35s ease both;
}

/* ==========================================================================
   Chat Input Area
   ========================================================================== */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

.chat-input-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    padding: 4px 4px 4px 8px;
}

.chat-input-wrapper:focus-within {
    border-color: var(--color-accent);
}

#input-question {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    color: var(--color-text);
    outline: none;
    min-height: 40px;
    padding-left: 4px;
    font-family: var(--font);
}

#input-question::placeholder {
    color: var(--color-text-secondary);
}

.btn-send {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--color-accent);
    color: #ffffff;
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition), opacity var(--transition);
    flex-shrink: 0;
}

.btn-send svg {
    display: block;
}

.btn-send:hover {
    opacity: 0.9;
}

.btn-send:active {
    transform: scale(0.92);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.hidden {
    display: none !important;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes pulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Landing exit animation */
.landing.exit {
    animation: fadeOut 300ms ease-out forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (min-width: 480px) {
    .chat-messages {
        padding: 24px;
    }
    .message {
        max-width: 80%;
    }
}

@media (min-width: 768px) {
    .landing {
        padding: 40px;
    }
    .chat-messages {
        padding: 32px;
    }
    .message {
        max-width: 75%;
    }
    .chat-input-area {
        padding: 16px 24px;
    }
}

@media (min-width: 1024px) {
    .message {
        max-width: 70%;
    }
}

/* ==========================================================================
   Tables (rendered from markdown)
   ========================================================================== */
.message-system table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
}

.message-system table th {
    background: var(--color-surface);
    font-weight: 600;
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid var(--color-border);
    font-size: 0.8rem;
}

.message-system table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--color-border);
}

.message-system table tr:last-child td {
    border-bottom: none;
}

.message-system table tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

/* =========================================================================
   Screenshot upload (web image support W4)
   ========================================================================= */
/* Ghost icon button (ChatGPT/Claude-style): no outline at rest, soft round
   hover fill. SVG icon is geometrically centered — no glyph-metric drift. */
.btn-attach {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    border-radius: 50%;
    cursor: pointer;
    transition: background var(--transition), color var(--transition),
                transform var(--transition);
    flex-shrink: 0;
}

.btn-attach svg {
    display: block;
}

.btn-attach:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--color-text);
}

.btn-attach:active {
    transform: scale(0.92);
}

.btn-attach:disabled {
    opacity: 0.4;
    cursor: default;
    background: transparent;
}

/* Thumbnail strip sits above the input pill. */
.image-preview-strip {
    display: flex;
    gap: 8px;
    padding: 0 8px 8px 12px;
}

.image-preview-item {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    flex-shrink: 0;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-preview-item.uploading img {
    opacity: 0.45;
}

.image-preview-item .upload-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--color-text);
}

.image-preview-item .btn-remove-image {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* document attachment chip in the preview strip */
.doc-preview-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background: var(--color-card);
    font-size: 0.82rem;
    color: var(--color-text);
    max-width: 100%;
}

.doc-preview-chip.uploading {
    opacity: 0.6;
}

.doc-preview-chip .btn-remove-image {
    position: static;
    flex-shrink: 0;
}

/* document label inside a sent user message */
.message-user .msg-doc {
    margin-top: 6px;
    font-size: 0.8rem;
    opacity: 0.85;
}

/* thumbnails inside a sent user message */
.message-user .msg-images {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.message-user .msg-images img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}
