/* Merak AI — paleta: duboko indigo/noćno plavo + bakreni akcent (fildžan kafe u sumrak) */
:root {
    --ink: #12141c;
    --ink-2: #1a1d29;
    --ink-3: #232636;
    --line: #2e3247;
    --paper: #f6f4ee;
    --copper: #c8703f;
    --copper-bright: #e08a54;
    --text: #e9e7de;
    --text-dim: #9a97a8;
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--ink);
    color: var(--text);
    font-family: var(--font-body);
}

/* ---------- Auth stranice ---------- */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 20%, #1c2032 0%, var(--ink) 65%);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--ink-2);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 40px 32px;
}

.auth-mark {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    color: var(--copper-bright);
    letter-spacing: -0.01em;
}

.auth-sub {
    color: var(--text-dim);
    margin: 6px 0 28px;
    font-size: 14px;
}

.auth-error {
    background: rgba(200, 70, 70, 0.15);
    border: 1px solid rgba(200, 70, 70, 0.4);
    color: #e0a0a0;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 18px;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-dim);
}

.auth-form input {
    background: var(--ink-3);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-body);
}

.auth-form input:focus {
    outline: 2px solid var(--copper);
    outline-offset: 1px;
}

.auth-form button {
    margin-top: 8px;
    background: var(--copper);
    color: #1a1005;
    border: none;
    border-radius: 8px;
    padding: 11px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.auth-form button:hover { background: var(--copper-bright); }

.auth-switch {
    margin-top: 22px;
    font-size: 13px;
    color: var(--text-dim);
    text-align: center;
}

.auth-switch a { color: var(--copper-bright); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ---------- App layout ---------- */
.app {
    display: grid;
    grid-template-columns: 270px 1fr;
    grid-template-rows: minmax(0, 1fr);  /* red je visine ekrana; sadržaj se skroluje unutar panela, ne cijela stranica */
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

body:has(.app) { overflow: hidden; }  /* izbornik ostaje fiksan, stranica se ne pomjera */

.sidebar {
    background: var(--ink-2);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    min-height: 0;
    height: 100%;
}

.sidebar-top { margin-bottom: 18px; flex: none; }

.brand {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    color: var(--copper-bright);
    margin-bottom: 16px;
    padding: 0 6px;
}

.btn-new {
    width: 100%;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.btn-new:hover { border-color: var(--copper); background: var(--ink-3); }

.conversation-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 8px;
    padding: 2px 4px 2px 10px;
}

.conversation-item a {
    flex: 1;
    display: block;
    padding: 9px 0;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item:hover { background: var(--ink-3); }
.conversation-item:hover a { color: var(--text); }
.conversation-item.active { background: var(--ink-3); }
.conversation-item.active a { color: var(--copper-bright); }

.delete-form button {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0;
    transition: opacity 0.1s ease;
}

.conversation-item:hover .delete-form button { opacity: 1; }
.delete-form button:hover { color: #e08080; }

.empty-hint { color: var(--text-dim); font-size: 13px; padding: 10px; }

.sidebar-bottom {
    flex: none;
    border-top: 1px solid var(--line);
    padding-top: 14px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-dim);
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
    text-decoration: underline;
    padding: 0;
}

.btn-link:hover { color: var(--copper-bright); }

/* ---------- Chat panel ---------- */
.chat-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    background: var(--paper);
    color: #262420;
}

.empty-state {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: 24px;
    padding-bottom: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    color: #6b6558;
}

.empty-mark {
    font-family: var(--font-display);
    font-size: 34px;
    color: var(--copper);
    margin-bottom: 10px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px 20%;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

@media (max-width: 900px) {
    .messages { padding: 24px 6%; }
}

.msg { display: flex; flex-direction: column; gap: 4px; }

.msg-role {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9c8f7a;
    font-weight: 600;
}

.msg-user .msg-role { color: #a8734a; }

.msg-bubble {
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.msg-user .msg-bubble {
    background: #ece6d8;
    border-radius: 12px;
    padding: 12px 16px;
    align-self: flex-start;
    max-width: 80%;
}

.msg-assistant .msg-bubble { color: #262420; }

.composer {
    border-top: 1px solid #e0dac8;
    padding: 14px 20%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--paper);
}

@media (max-width: 900px) {
    .composer { padding: 14px 6%; }
}

.composer-row {
    display: flex;
    gap: 10px;
}

.web-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: #8a8270;
    cursor: pointer;
    user-select: none;
    padding-left: 2px;
}

.web-toggle input {
    cursor: pointer;
    accent-color: var(--copper);
}

.web-toggle:has(input:checked) { color: var(--copper); font-weight: 600; }

.composer textarea {
    flex: 1;
    resize: none;
    border: 1px solid #d8d0ba;
    border-radius: 10px;
    padding: 12px 14px;
    font-family: var(--font-body);
    font-size: 14.5px;
    max-height: 160px;
    background: #fffdf8;
}

.composer textarea:focus {
    outline: 2px solid var(--copper);
    outline-offset: 1px;
}

.composer button {
    background: var(--copper);
    color: #1a1005;
    border: none;
    border-radius: 10px;
    padding: 0 22px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.composer .attach-btn {
    background: #fffdf8;
    border: 1px solid #d8d0ba;
    padding: 0 14px;
    font-size: 18px;
}
.composer .attach-btn:hover { background: #fffdf8; border-color: var(--copper); }

.attach-pill {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    background: #f3ecd8;
    border: 1px solid var(--copper);
    border-radius: 999px;
    padding: 4px 6px 4px 12px;
    font-size: 13px;
    color: #5a5342;
}
.attach-pill[hidden] { display: none; }
.attach-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer .attach-pill button {
    background: none;
    color: #5a5342;
    padding: 0 6px;
    font-size: 18px;
    line-height: 1;
}

.composer button:hover { background: var(--copper-bright); }
.composer button:disabled { opacity: 0.5; cursor: default; }

.msg-typing .msg-bubble {
    color: #9c8f7a;
    font-style: italic;
}

.msg-error .msg-bubble { color: #b4483f; }

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.chip {
    border: 1px solid #d8d0ba;
    background: #fffdf8;
    color: #5a5342;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12.5px;
    cursor: pointer;
    font-family: var(--font-body);
}

.chip:hover { border-color: var(--copper); color: var(--copper); }

.chat-image { display: block; max-width: 100%; max-height: 70vh; border-radius: 8px; margin: 6px 0; }


/* ---------- Mobilni prikaz ---------- */
.topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
    .app { grid-template-columns: minmax(0, 1fr); }

    /* izbornik je ladica koja se otvara preko sadržaja */
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(300px, 86vw);
        height: 100vh;
        height: 100dvh;
        z-index: 30;
        transform: translateX(-102%);
        transition: transform 0.22s ease;
        padding-top: max(20px, env(safe-area-inset-top));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    .app.menu-open .sidebar { transform: none; box-shadow: 6px 0 28px rgba(0, 0, 0, 0.45); }
    .app.menu-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 20;
        background: rgba(0, 0, 0, 0.5);
    }

    /* gornja traka sa tipkom za izbornik i novim razgovorom - uvijek na vidiku */
    .topbar {
        display: flex;
        align-items: center;
        gap: 10px;
        flex: none;
        padding: 8px 10px;
        padding-top: max(8px, env(safe-area-inset-top));
        background: var(--ink-2);
        border-bottom: 1px solid var(--line);
    }
    .topbar form { margin: 0; }
    .topbar-title {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: var(--text);
        font-size: 14px;
    }
    .topbar-btn {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        border: 1px solid var(--line);
        background: transparent;
        color: var(--copper-bright);
        font-size: 20px;
        line-height: 1;
        cursor: pointer;
    }
    .topbar-btn:active { background: var(--ink-3); }

    .messages { padding: 16px 12px; gap: 16px; }
    .msg-bubble { overflow-wrap: anywhere; }
    .composer { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .composer textarea { font-size: 16px; }  /* manje od 16px izaziva zumiranje na iPhoneu */

    /* tipke za brze radnje: jedan red koji se pomjera prstom umjesto 4 reda */
    .quick-actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin-bottom: 6px;
    }
    .quick-actions::-webkit-scrollbar { display: none; }
    .chip { flex: none; white-space: nowrap; padding: 7px 12px; }

    .web-toggle { font-size: 12px; }
    .chat-image { max-height: 60vh; }
    .empty-state { padding: 24px 20px; text-align: center; }
}

/* na ekranima bez miša nema "hover", pa tipka za brisanje mora biti stalno vidljiva */
@media (hover: none) {
    .delete-form button { opacity: 0.7; }
}


/* ---------- Početni ekran i grupe dugmadi ---------- */
.empty-sub { margin: 0 0 18px; font-size: 15px; }

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
    width: min(760px, 92%);
}

.mode-grid form { display: contents; }

.mode-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    text-align: left;
    padding: 14px 16px;
    border: 1px solid #d8d0ba;
    border-radius: 12px;
    background: #fffdf8;
    color: #5a5342;
    font-family: var(--font-body);
    font-size: 12.5px;
    cursor: pointer;
}

.mode-card strong { font-size: 14.5px; color: #2c2a22; }
.mode-card:hover { border-color: var(--copper); }
.mode-icon { font-size: 22px; }
.mode-soon { opacity: 0.55; cursor: default; border-style: dashed; }
.mode-soon:hover { border-color: #d8d0ba; }

.mode-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.mode-tab {
    flex: none;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: #6b6558;
    padding: 4px 10px;
    font-size: 12.5px;
    font-family: var(--font-body);
    cursor: pointer;
    white-space: nowrap;
}

.mode-tab.active { color: var(--copper); border-bottom-color: var(--copper); font-weight: 600; }
.chip[hidden] { display: none; }

/* ---------- Skica tlocrta ---------- */
.sketch-modal { position: fixed; inset: 0; z-index: 50; background: rgba(8, 9, 14, 0.75); display: flex; align-items: center; justify-content: center; padding: 12px; }
.sketch-modal[hidden] { display: none; }
.sketch-box { width: 100%; max-width: 1000px; max-height: 100%; display: flex; flex-direction: column; gap: 10px; background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.sketch-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sk-tool, .sk-act { background: var(--ink-3); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; font-size: 13px; }
.sk-tool.active { border-color: var(--copper); color: var(--copper-bright); }
.sk-scale { margin-left: auto; font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.sk-scale input { width: 64px; background: var(--ink); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
#sketch-canvas { width: 100%; height: auto; min-height: 0; border-radius: 8px; touch-action: none; cursor: crosshair; background: #faf8f3; }
.sketch-foot { display: flex; gap: 12px; align-items: center; }
.sk-hint { flex: 1; font-size: 12px; color: var(--text-dim); }
@media (max-width: 720px) { .sk-scale { margin-left: 0; } .sketch-foot { flex-wrap: wrap; } }

a.mode-card { text-decoration: none; }
.editor-link {
    display: inline-block; margin: 4px 0; padding: 6px 12px; border-radius: 8px;
    background: var(--copper); color: #fff !important; font-weight: 600; text-decoration: none;
}
.editor-link:hover { background: var(--copper-bright); }
.chat-audio{width:100%;max-width:460px;margin:8px 0;display:block}.song-dl{font-size:12.5px}

/* ---------- Studio pjesme ---------- */
.song-box { width: 100%; max-width: 760px; max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 10px; background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; color: var(--text); }
.song-box h3 { margin: 0; font: 600 18px var(--font-display); }
.sg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.sg-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-dim); }
.sg-grid .sg-wide { grid-column: 1 / -1; }
.sg-grid select, .sg-grid input:not([type=checkbox]):not([type=range]), .sg-grid textarea { background: var(--ink-3); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; font: 14px var(--font-body); width: 100%; box-sizing: border-box; }
.sg-grid fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; min-width: 0; }
.sg-grid legend { font-size: 12.5px; color: var(--text-dim); padding: 0 4px; }
.sg-grid .sg-chk { flex-direction: row; align-items: center; gap: 5px; color: var(--text); font-size: 13px; }
@media (max-width: 640px) { .sg-grid { grid-template-columns: 1fr; } }
