/* ==============================================
   Wort des Tages – Stylesheet
   Design: Editorial / Refined Minimalism
   ============================================== */

:root {
    --ink: #1a1a2e;
    --ink-soft: #4a4a6a;
    --ink-muted: #8888aa;
    --paper: #faf9f7;
    --paper-warm: #f5f0e8;
    --paper-card: #ffffff;
    --accent: #c8893a;
    --accent-dark: #a06828;
    --accent-light: #f5e6d0;
    --blue: #2d5fa3;
    --blue-light: #e8eef8;
    --purple: #7c3aed;
    --purple-light: #f0ebff;
    --success: #2d7a4f;
    --error: #c0392b;
    --border: #e8e4dc;
    --shadow-sm: 0 1px 4px rgba(26,26,46,0.07);
    --shadow-md: 0 4px 16px rgba(26,26,46,0.10);
    --shadow-lg: 0 8px 32px rgba(26,26,46,0.13);
    --radius: 16px;
    --radius-sm: 8px;
    --radius-lg: 24px;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'DM Sans', system-ui, sans-serif;
    --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 16px;
    line-height: 1.6;
    /* Subtle paper texture via gradient */
    background-image: 
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(200,137,58,0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 110%, rgba(45,95,163,0.05) 0%, transparent 60%);
}

.container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px;
}

/* === Header === */
.site-header {
    background: var(--paper-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 14px 0 0;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    line-height: 1;
}

.logo-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.logo-sub {
    font-size: 0.72rem;
    color: var(--ink-muted);
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.quota-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--accent-light);
    color: var(--accent-dark);
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(200,137,58,0.2);
    transition: var(--transition);
}

.quota-badge.low {
    background: #fde8e8;
    color: var(--error);
    border-color: rgba(192,57,43,0.2);
}

.quota-icon { font-size: 10px; }

/* === Mode Tabs === */
.mode-tabs {
    display: flex;
    gap: 4px;
    padding-bottom: 0;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--ink-muted);
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tab-btn:hover { color: var(--ink); }

.tab-btn.active[data-mode="dictionary"] {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

.tab-btn.active[data-mode="translate"] {
    color: var(--purple);
    border-bottom-color: var(--purple);
}

/* === Language Bar === */
.lang-bar {
    background: var(--paper-warm);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
}

.lang-bar-inner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-select {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--paper-card);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888aa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.lang-select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-light); }

.swap-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--paper-card);
    color: var(--ink-soft);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
    font-weight: bold;
}

.swap-btn:hover { background: var(--paper-warm); color: var(--ink); transform: rotate(180deg); }

/* === Main Area === */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-top: 20px;
    padding-bottom: 20px;
    gap: 12px;
}

/* === Chat Window === */
.chat-window {
    flex: 1;
    min-height: 380px;
    max-height: calc(100vh - 340px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.chat-window::-webkit-scrollbar { width: 4px; }
.chat-window::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* === Welcome State === */
.welcome-state {
    text-align: center;
    padding: 40px 20px;
    animation: fadeInUp 0.5s ease;
}

.welcome-emoji {
    font-size: 3.5rem;
    margin-bottom: 16px;
    display: block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.welcome-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 24px;
    letter-spacing: -0.01em;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 500px;
    margin: 0 auto;
}

.suggestion-chip {
    padding: 8px 16px;
    background: var(--paper-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ink-soft);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.suggestion-chip:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* === Messages === */
.messages { display: flex; flex-direction: column; gap: 12px; }

.message-row {
    display: flex;
    gap: 10px;
    animation: fadeInUp 0.3s ease;
}

.message-row.user { flex-direction: row-reverse; }

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

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.avatar.bot {
    background: var(--blue-light);
    border: 1px solid rgba(45,95,163,0.15);
}

.bubble {
    max-width: 78%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.92rem;
    line-height: 1.65;
    box-shadow: var(--shadow-sm);
}

.bubble.bot {
    background: var(--paper-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    color: var(--ink);
}

.bubble.user-dict {
    background: var(--blue);
    color: white;
    border-bottom-right-radius: 4px;
}

.bubble.user-trans {
    background: var(--purple);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Markdown im Bot-Bubble */
.bubble.bot strong { font-weight: 700; color: var(--ink); }
.bubble.bot em { font-style: italic; color: var(--ink-soft); }
.bubble.bot ul { list-style: disc; padding-left: 1.3em; margin: 6px 0; }
.bubble.bot ol { list-style: decimal; padding-left: 1.3em; margin: 6px 0; }
.bubble.bot li { margin-bottom: 3px; }
.bubble.bot h3 { font-family: var(--font-display); font-size: 1em; font-weight: 700; margin: 10px 0 4px; color: var(--ink); }
.bubble.bot code { background: var(--paper-warm); padding: 2px 6px; border-radius: 4px; font-size: 0.88em; border: 1px solid var(--border); }
.bubble.bot p { margin-bottom: 6px; }
.bubble.bot p:last-child { margin-bottom: 0; }
.bubble.bot hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

/* === Loading Dots === */
.typing-dots {
    display: flex;
    gap: 5px;
    padding: 4px 0;
}

.dot {
    width: 7px;
    height: 7px;
    background: var(--ink-muted);
    border-radius: 50%;
    animation: bounce 1s infinite;
}

.dot:nth-child(2) { animation-delay: 0.15s; }
.dot:nth-child(3) { animation-delay: 0.3s; }

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

/* === Input Area === */
.input-area {
    background: var(--paper-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 12px 14px 10px;
}

.input-box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--ink);
    background: transparent;
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
    padding: 4px 0;
}

.chat-input::placeholder { color: var(--ink-muted); }

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--blue);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(45,95,163,0.35);
}

.send-btn:hover:not(:disabled) { background: var(--accent-dark); transform: scale(1.05); }
.send-btn:disabled { background: var(--border); box-shadow: none; cursor: not-allowed; color: var(--ink-muted); }
.send-btn.translate-mode { background: var(--purple); box-shadow: 0 2px 8px rgba(124,58,237,0.35); }
.send-btn.translate-mode:hover:not(:disabled) { background: #6d28d9; }

.input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    min-height: 22px;
}

.reset-btn {
    border: none;
    background: none;
    color: var(--ink-muted);
    font-size: 0.78rem;
    font-family: var(--font-body);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: var(--transition);
}

.reset-btn:hover { color: var(--error); background: #fde8e8; }

.char-count {
    font-size: 0.75rem;
    color: var(--ink-muted);
    margin-left: auto;
}

.char-count.warn { color: var(--error); font-weight: 600; }

/* === Limit Box === */
.limit-box {
    text-align: center;
    padding: 20px;
    background: var(--paper-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--error);
}

.limit-box small { display: block; color: var(--ink-muted); margin-top: 4px; font-size: 0.82rem; }

/* === Footer Note === */
.footer-note {
    text-align: center;
    font-size: 0.75rem;
    color: var(--ink-muted);
}

.footer-note a { color: var(--ink-muted); text-decoration: underline; }
.footer-note a:hover { color: var(--ink); }

/* === Error bubble === */
.bubble.error {
    background: #fde8e8;
    border-color: rgba(192,57,43,0.2);
    color: var(--error);
}

/* === Responsive === */
@media (max-width: 600px) {
    .logo-title { font-size: 1.1rem; }
    .bubble { max-width: 88%; font-size: 0.88rem; }
    .welcome-title { font-size: 1.1rem; }
    .chat-window { max-height: calc(100vh - 360px); min-height: 280px; }
}
