/* ============================================================
   Linha Editorial — design mobile-first elegante
   ============================================================ */

:root {
    --accent: #b8956a;
    --accent-soft: #e8d9c4;
    --bg: #faf7f2;
    --card: #ffffff;
    --text: #1a1a1a;
    --text-soft: #6b6b6b;
    --border: #ece7df;
    --shadow: 0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04);
    --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

img { max-width: 100%; }

/* ===== Login ===== */
body.login-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(160deg, #f5ede0 0%, #faf7f2 60%, #f0e4d2 100%);
}
.login-card {
    background: var(--card);
    border-radius: 18px;
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
}
.login-card h1 {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 600;
}
.login-card .subtitle {
    margin: 0 0 24px;
    color: var(--text-soft);
    font-size: 14px;
}
.login-card label {
    display: block;
    margin-bottom: 14px;
}
.login-card label span {
    display: block;
    font-size: 13px;
    color: var(--text-soft);
    margin-bottom: 6px;
}
input[type="text"], input[type="password"], textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    -webkit-appearance: none;
}
input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(184,149,106,.15);
}
button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: var(--text);
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: opacity .2s;
}
button:active { opacity: .85; }
button.primary {
    background: var(--accent);
}
button.primary.big {
    padding: 16px;
    font-size: 16px;
    letter-spacing: .3px;
}
button:disabled {
    opacity: .5;
    cursor: not-allowed;
}
.alert {
    background: #fdecea;
    border-left: 3px solid #d44;
    padding: 10px 12px;
    border-radius: 6px;
    color: #911;
    font-size: 14px;
    margin-bottom: 16px;
}

/* ===== Topbar ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    padding-top: max(18px, env(safe-area-inset-top));
}
.hello { font-weight: 600; font-size: 16px; }
.date {
    color: var(--text-soft);
    font-size: 13px;
    text-transform: capitalize;
    margin-top: 2px;
}
.icon-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
    font-size: 18px;
}

/* ===== App layout ===== */
.app {
    padding: 16px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ===== Cards ===== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.card .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 8px;
}
.card h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
}
.theme-card {
    background: linear-gradient(135deg, var(--accent-soft) 0%, #fff 100%);
    border: 1px solid var(--border);
}
.parable, .hook {
    margin: 0;
    color: var(--text);
    font-size: 15px;
    line-height: 1.65;
}
.link-bio {
    display: inline-block;
    margin-top: 12px;
    color: var(--accent);
    font-size: 14px;
    text-decoration: none;
    font-weight: 500;
}
.empty {
    text-align: center;
    color: var(--text-soft);
    padding: 40px 20px;
}

/* ===== Stories output ===== */
.stories-output {
    margin-top: 16px;
    font-size: 15px;
    line-height: 1.7;
    white-space: pre-wrap;
    color: var(--text);
}
.stories-output:empty { display: none; }
.stories-output .meta {
    color: var(--text-soft);
    font-size: 13px;
    margin-top: 10px;
}

/* ===== Chat ===== */
.chat-card .hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-soft);
}
.chat-history {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}
.chat-history:empty { display: none; }
.bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.55;
    max-width: 92%;
    white-space: pre-wrap;
}
.bubble.user {
    background: var(--accent);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.bubble.ai {
    background: var(--bg);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.chat-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-form textarea {
    resize: none;
    min-height: 60px;
}

/* ===== Loading ===== */
.loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-soft);
    font-size: 14px;
}
.loading::before {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Admin ===== */
.admin-shell {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}
.admin-shell h1 { margin-top: 0; }
.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.admin-tabs a {
    padding: 10px 16px;
    text-decoration: none;
    color: var(--text-soft);
    font-size: 14px;
    border-bottom: 2px solid transparent;
}
.admin-tabs a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 500;
}
.row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.row > * { flex: 1; min-width: 0; }
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 14px;
}
th, td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
th { font-weight: 600; color: var(--text-soft); font-size: 12px; text-transform: uppercase; }
textarea.tall { min-height: 220px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.success {
    background: #ecfdf3;
    border-left: 3px solid #16a34a;
    padding: 10px 12px;
    border-radius: 6px;
    color: #14532d;
    font-size: 14px;
    margin-bottom: 16px;
}
.btn-link {
    background: none;
    color: var(--accent);
    width: auto;
    padding: 0;
    font-size: 13px;
    text-decoration: underline;
}
