/* ============================================
   NeroRu — Minimalist Design System
   ============================================ */

/* ===== FONTS ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

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

/* ===== DARK THEME (default) ===== */
:root {
    --bg:          #1a1a1a;
    --bg-2:        #222222;
    --bg-3:        #2a2a2a;
    --bg-4:        #333333;
    --bg-hover:    #2e2e2e;
    --surface:     #242424;
    --border:      #383838;
    --border-2:    #444444;

    --text-1:      #ececec;
    --text-2:      #a0a0a0;
    --text-3:      #686868;

    --accent:      #10a37f;
    --accent-dim:  rgba(16,163,127,0.12);
    --accent-border: rgba(16,163,127,0.25);

    --red:         #e5534b;
    --yellow:      #d4a017;

    --radius-sm:   8px;
    --radius:      12px;
    --radius-lg:   16px;
    --radius-xl:   24px;

    --shadow-sm:   0 1px 3px rgba(0,0,0,0.3);
    --shadow:      0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg:   0 8px 32px rgba(0,0,0,0.5);

    --sidebar-w:   256px;
    --chat-max:    720px;
    --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition:  0.15s ease;
}

/* ===== LIGHT THEME ===== */
body.light {
    --bg:          #f9f9f9;
    --bg-2:        #f2f2f2;
    --bg-3:        #ebebeb;
    --bg-4:        #e0e0e0;
    --bg-hover:    #eeeeee;
    --surface:     #ffffff;
    --border:      #e0e0e0;
    --border-2:    #d0d0d0;

    --text-1:      #1a1a1a;
    --text-2:      #5a5a5a;
    --text-3:      #999999;

    --shadow-sm:   0 1px 3px rgba(0,0,0,0.08);
    --shadow:      0 4px 16px rgba(0,0,0,0.1);
    --shadow-lg:   0 8px 32px rgba(0,0,0,0.15);
}

/* ===== BASE ===== */
html { height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-1);
    height: 100%;
    overflow: hidden;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app { height: 100vh; display: flex; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition);
    overflow: hidden;
}

/* Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px 14px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-1);
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.logo-icon {
    width: 30px;
    height: 30px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* New chat button */
.sidebar-top { padding: 0 10px 10px; flex-shrink: 0; }

.new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    cursor: pointer;
    font-size: 13.5px;
    font-family: var(--font);
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}

.new-chat-btn:hover {
    background: var(--bg-hover);
    color: var(--text-1);
    border-color: var(--border-2);
}

/* Sessions */
.sidebar-sessions {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-sessions::-webkit-scrollbar { width: 4px; }
.sidebar-sessions::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.session-group-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 10px 6px 4px;
}

.session-item {
    position: relative;
    padding: 8px 30px 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all var(--transition);
    margin-bottom: 1px;
}

.session-item:hover { background: var(--bg-hover); color: var(--text-1); }
.session-item.active { background: var(--bg-3); color: var(--text-1); font-weight: 500; }

/* Delete button */
.session-delete-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-3);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all var(--transition);
    font-family: var(--font);
    padding: 0;
}

.session-item:hover .session-delete-btn { display: flex; }
.session-delete-btn:hover { background: rgba(229,83,75,0.15); color: var(--red); }

/* Sidebar bottom */
.sidebar-bottom {
    padding: 10px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
}

.sidebar-close-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    border-radius: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.sidebar-close-btn:hover { background: var(--bg-hover); color: var(--text-1); }

/* User info */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.user-info:hover { background: var(--bg-hover); }

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.user-email {
    font-size: 13px;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.user-sub-badge {
    font-size: 10px;
    font-weight: 700;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    border-radius: 5px;
    padding: 2px 7px;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

/* Auth buttons */
.sidebar-auth {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ===== MAIN ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
    min-width: 0;
}

/* ===== TOPBAR (mobile) ===== */
.topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.topbar-logo {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-1);
    letter-spacing: -0.02em;
}

.hamburger {
    width: 34px;
    height: 34px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-2);
    transition: all var(--transition);
}

.hamburger:hover { background: var(--bg-hover); color: var(--text-1); }

/* ===== VERIFY NOTICE ===== */
.verify-notice {
    margin: 10px 16px 0;
    padding: 9px 14px;
    background: rgba(212,160,23,0.08);
    border: 1px solid rgba(212,160,23,0.2);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--yellow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}

.verify-notice a {
    color: var(--yellow);
    text-decoration: underline;
    cursor: pointer;
    white-space: nowrap;
    font-size: 12px;
}

/* ===== CHAT AREA ===== */
.chat-area {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.chat-area::-webkit-scrollbar { width: 5px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

#messages-container { padding: 16px 0 8px; }

/* ===== WELCOME SCREEN ===== */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    padding: 40px 24px;
    text-align: center;
}

.welcome-logo {
    width: 64px;
    height: 64px;
    background: var(--accent);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    box-shadow: 0 0 0 1px var(--accent-border), 0 8px 24px rgba(16,163,127,0.2);
}

.welcome-title {
    font-size: 26px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}

.welcome-subtitle {
    font-size: 15px;
    color: var(--text-2);
    max-width: 420px;
    margin-bottom: 36px;
    line-height: 1.5;
}

.welcome-examples {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 520px;
    width: 100%;
}

.example-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    color: var(--text-2);
    transition: all var(--transition);
    font-family: var(--font);
}

.example-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent-border);
    color: var(--text-1);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.example-card strong {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 3px;
}

/* ===== MESSAGES ===== */
.message {
    display: flex;
    gap: 14px;
    padding: 14px 20px;
    animation: msgIn 0.18s ease;
    max-width: 100%;
}

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

.message.assistant { background: transparent; }
.message.user      { justify-content: flex-end; background: transparent; }

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
}

.message.assistant .message-avatar { background: var(--accent); }
.message.user      .message-avatar { background: var(--bg-4); order: 2; }

.message-content { flex: 1; min-width: 0; max-width: var(--chat-max); }

.message.user .message-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px 16px 4px 16px;
    padding: 11px 16px;
    max-width: 78%;
    flex: none;
}

.message-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-1);
    word-break: break-word;
}

/* Markdown */
.message-text strong, .message-text b { font-weight: 600; }
.message-text em, .message-text i { font-style: italic; }
.message-text h1 { font-size: 20px; font-weight: 700; margin: 16px 0 8px; letter-spacing: -0.02em; }
.message-text h2 { font-size: 17px; font-weight: 600; margin: 14px 0 6px; }
.message-text h3 { font-size: 15px; font-weight: 600; margin: 12px 0 4px; }
.message-text p { margin: 0 0 10px; }
.message-text p:last-child { margin: 0; }
.message-text ul, .message-text ol { padding-left: 22px; margin: 8px 0; }
.message-text li { margin: 4px 0; }

.message-text code {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px 6px;
    font-size: 13px;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    color: var(--text-1);
}

.message-text pre {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 13px;
    line-height: 1.6;
}

.message-text pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}

/* Tables */
.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
}

.message-text th {
    background: var(--bg-3);
    border: 1px solid var(--border);
    padding: 8px 12px;
    font-weight: 600;
    text-align: left;
}

.message-text td {
    border: 1px solid var(--border);
    padding: 7px 12px;
}

.message-text tr:nth-child(even) td { background: var(--bg-2); }
.message-text tr:hover td { background: var(--bg-hover); }

/* Streaming cursor */
.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--text-2);
    margin-left: 2px;
    border-radius: 1px;
    animation: blink 0.9s steps(1) infinite;
    vertical-align: text-bottom;
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 2px;
}

.typing-dot {
    width: 5px;
    height: 5px;
    background: var(--text-3);
    border-radius: 50%;
    animation: bounce 1.3s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40%           { transform: translateY(-5px); opacity: 1; }
}

/* ===== EXPORT BUTTONS ===== */
.export-btns {
    display: flex;
    gap: 5px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-3);
    font-size: 12px;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
}

.export-btn:hover {
    background: var(--bg-hover);
    color: var(--text-1);
    border-color: var(--border-2);
}

/* ===== INPUT AREA ===== */
.input-area {
    padding: 12px 16px 18px;
    background: var(--bg);
    flex-shrink: 0;
}

.input-wrapper {
    max-width: var(--chat-max);
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    background: var(--surface);
    border: 1px solid #d0d0d0;
    border-radius: var(--radius-xl);
    padding: 8px 10px 8px 18px;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-box {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-1);
    font-size: 15px;
    font-family: var(--font);
    resize: none;
    min-height: 26px;
    max-height: 180px;
    overflow-y: auto;
    line-height: 1.6;
    padding: 3px 0;
    scrollbar-width: thin;
}

.input-box::placeholder { color: #999999; }
.input-box::-webkit-scrollbar { width: 3px; }
.input-box::-webkit-scrollbar-thumb { background: var(--border); }

/* Image gen button */
.img-gen-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    transition: all var(--transition);
    position: static;
}

.img-gen-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent-border);
}

.img-gen-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Send button */
.send-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all var(--transition);
    position: static;
}

.send-btn:hover { background: #0d8f6f; transform: scale(1.05); }
.send-btn:active { transform: scale(0.96); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Input footer */
.input-footer {
    max-width: var(--chat-max);
    margin: 8px auto 0;
    text-align: center;
    font-size: 12px;
    color: var(--text-3);
    line-height: 1.4;
}

/* Free counter */
.free-counter {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--accent-dim);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 6px;
}

/* Image mode bar */
#image-mode-bar { max-width: var(--chat-max); margin: 0 auto 8px; transition: all 0.2s ease; }

/* ===== BUTTONS ===== */
.btn-primary {
    width: 100%;
    padding: 11px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
    letter-spacing: -0.01em;
}

.btn-primary:hover { background: #0d8f6f; }
.btn-primary:active { transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
}

.btn-ghost:hover { background: var(--bg-hover); color: var(--text-1); border-color: var(--border-2); }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(6px);
}

.modal-overlay.hidden { display: none; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
    position: relative;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(-8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-1);
    margin-bottom: 6px;
    letter-spacing: -0.03em;
}

.modal-subtitle {
    font-size: 14px;
    color: var(--text-2);
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.modal-close:hover { background: var(--bg-hover); color: var(--text-1); }

/* Form */
.form-group { margin-bottom: 14px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.form-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 13px;
    color: var(--text-1);
    font-size: 14.5px;
    font-family: var(--font);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-input::placeholder { color: var(--text-3); }

.modal-switch {
    text-align: center;
    margin-top: 18px;
    font-size: 13.5px;
    color: var(--text-2);
}

.modal-switch a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

.modal-switch a:hover { text-decoration: underline; }

/* ===== PAYMENT MODAL ===== */
.payment-modal { max-width: 500px; }

.plan-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 18px 0;
}

.plan-card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    position: relative;
}

.plan-card:hover { border-color: var(--accent-border); background: var(--accent-dim); }
.plan-card.selected { border-color: var(--accent); background: var(--accent-dim); }

.plan-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 10px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.plan-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 8px;
}

.plan-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.03em;
}

.plan-price span { font-size: 14px; font-weight: 400; color: var(--text-2); }
.plan-per { font-size: 11px; color: var(--text-3); margin-top: 3px; }

.plan-single {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
}

/* ===== USER MENU ===== */
.user-menu {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 8px;
    right: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    z-index: 50;
    animation: modalIn 0.15s ease;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13.5px;
    color: var(--text-1);
    transition: background var(--transition);
    border: none;
    width: 100%;
    background: transparent;
    font-family: var(--font);
    text-align: left;
}

.user-menu-item:hover { background: var(--bg-hover); }
.user-menu-item.danger { color: var(--red); }
.divider { height: 1px; background: var(--border); margin: 2px 0; }

/* ===== THEME TOGGLE ===== */
.theme-toggle-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    transition: all var(--transition);
    flex-shrink: 0;
}

.theme-toggle-btn:hover { background: var(--bg-hover); color: var(--text-1); }

.icon-sun { display: none; }
.icon-moon { display: block; }
body.light .icon-sun { display: block; }
body.light .icon-moon { display: none; }

/* В светлой теме — белый фон у input с тенью */
body.light .input-wrapper {
    background: #ffffff;
    box-shadow: 0 1px 8px rgba(0,0,0,0.08);
    border-color: #d8d8d8;
}

/* В тёмной теме — чуть светлее чем фон */
body:not(.light) .input-wrapper {
    background: #2a2a2a;
}

/* ===== TOAST ===== */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 16px;
    font-size: 13.5px;
    color: var(--text-1);
    box-shadow: var(--shadow);
    max-width: 340px;
    animation: toastIn 0.2s ease;
    font-family: var(--font);
}

.toast.success { border-color: var(--accent-border); }
.toast.error   { border-color: rgba(229,83,75,0.3); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .topbar { display: flex; }
    .sidebar-close-btn { display: flex; }

    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        width: min(280px, 85vw);
    }

    .sidebar.open { transform: translateX(0); }

    .welcome-examples { grid-template-columns: 1fr; }
    .welcome-title { font-size: 22px; }
    .welcome-screen { min-height: 60vh; padding: 24px 16px; }

    .message { padding: 10px 14px; }
    .message.user .message-content { max-width: 88%; }

    .input-area { padding: 8px 12px 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
    .input-box { font-size: 16px !important; }
    .send-btn, .img-gen-btn { width: 32px; height: 32px; }

    .modal-overlay { align-items: flex-start; padding: 0; }
    .modal { border-radius: 0 0 var(--radius-lg) var(--radius-lg); max-width: 100%; width: 100%; padding: 22px 20px 28px; max-height: 90dvh; overflow-y: auto; }

    .plan-grid { grid-template-columns: 1fr; }
    .plan-single { grid-column: 1; }

    .session-delete-btn { display: flex !important; }

    #toast-container { bottom: 12px; right: 12px; left: 12px; }
    .toast { max-width: 100%; }

    html, body { height: 100%; }
    #app { height: 100dvh; }
    .main { height: 100dvh; }
    .chat-area { -webkit-overflow-scrolling: touch; }
    .input-area { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--border); }
}

@media (max-width: 380px) {
    .welcome-title { font-size: 19px; }
    .message { padding: 8px 10px; }
}

/* ===== DOC/PDF/XLS BUTTONS ===== */
.export-btn svg { opacity: 0.7; }

/* ===== IMAGE GENERATION UI ===== */
.img-plan-card {
    transition: all var(--transition);
}

.img-plan-card:hover {
    border-color: var(--accent-border) !important;
    background: var(--accent-dim) !important;
}

/* Белый фон textarea в обеих темах */
body.light .input-wrapper,
body:not(.light) .input-wrapper {
    background: #ffffff !important;
}
body.light .input-box,
body:not(.light) .input-box {
    color: #1a1a1a !important;
    background: transparent !important;
}
body.light .input-box::placeholder,
body:not(.light) .input-box::placeholder {
    color: #aaaaaa !important;
}

/* Скрываем футер на мобильном */
@media (max-width: 768px) {
    .input-footer { display: block; padding-top: 4px; }
    .footer-extra { display: none; }
    .free-counter-row { display: flex; }
}

/* Два счётчика под textarea */
.free-counter-row {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}
.counter-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--accent-dim);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 12px;
    font-weight: 500;
    transition: all var(--transition);
}
.counter-pill:hover { background: rgba(16,163,127,0.18); }
.counter-pill.counter-empty {
    background: rgba(229,83,75,0.1);
    border-color: rgba(229,83,75,0.25);
    color: var(--red);
}
.counter-pill.counter-empty:hover { background: rgba(229,83,75,0.18); }


/* iOS safe-area — отступ топбара под статус-бар */
@supports (padding-top: env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        .topbar {
            padding-top: calc(11px + env(safe-area-inset-top));
        }
    }
}


/* iOS safe-area — отступ шапки сайдбара под статус-бар */
@supports (padding-top: env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        .sidebar-logo {
            padding-top: calc(18px + env(safe-area-inset-top));
        }
    }
}


/* iOS safe-area — отступ модалок под статус-бар */
@supports (padding-top: env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        .modal {
            padding-top: calc(22px + env(safe-area-inset-top)) !important;
        }
    }
}


/* iOS safe-area — крестик закрытия модалки под статус-бар */
@supports (top: env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        .modal-close {
            top: calc(14px + env(safe-area-inset-top)) !important;
        }
    }
}

/* Затемнение за сайдбаром на мобильном */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(2px);
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
/* Оверлей только на мобильном; сайдбар поверх него */
@media (min-width: 769px) {
    .sidebar-overlay { display: none; }
}
@media (max-width: 768px) {
    .sidebar { z-index: 100; }
}
