:root {
    --bg-color: #f5f5f5;
    --text-color: #333;
    --muted-color: #888;
    --card-bg: #ffffff;
    --primary-color: #2196F3;
    --primary-hover: #1976D2;
    --accent-color: #ff4081;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #121212;
        --text-color: #e0e0e0;
        --muted-color: #999;
        --card-bg: #1e1e1e;
        --primary-color: #bb86fc;
        --primary-hover: #9965f4;
    }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    height: 100dvh;          /* altura real visible (se ajusta al teclado) */
    display: flex;
    justify-content: center;
    overflow: hidden;
}

/* Contenido arriba (no centrado) para que el teclado no tape el botón */
.container {
    width: 90%;
    max-width: 500px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-top: 20px;
}

[hidden] { display: none !important; }

.input-group { position: relative; width: 100%; }

textarea {
    width: 100%;
    height: 220px;
    padding: 15px;
    padding-bottom: 60px;
    border-radius: 12px;
    border: 2px solid transparent;
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 18px;
    font-family: inherit;
    resize: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: border-color 0.3s;
}

textarea:focus { outline: none; border-color: var(--primary-color); }

.voice-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.voice-btn.recording {
    background: var(--accent-color);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.main-btn {
    width: 100%;
    padding: 15px;
    border-radius: 12px;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.1s, background-color 0.3s;
}

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

.status { text-align: center; font-size: 14px; min-height: 20px; }

.offline-badge {
    background: #ffa000;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    text-align: center;
    display: none;
}

/* Botón Historial: pequeño y discreto, al fondo */
.history-btn {
    margin-top: auto;
    margin-bottom: 14px;
    align-self: center;
    background: none;
    border: none;
    color: var(--muted-color);
    font-size: 13px;
    padding: 8px 16px;
    cursor: pointer;
}

/* ---------- Historial ---------- */
.history-view { gap: 10px; }

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

.history-title { font-weight: bold; font-size: 18px; }

.link-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 16px;
    padding: 6px 0;
    cursor: pointer;
}

.history-list {
    list-style: none;
    margin: 0;
    padding: 0 0 20px;
    overflow-y: auto;
    flex: 1;
}

.history-list li {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    font-size: 15px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.history-list .date { color: var(--muted-color); font-size: 13px; }

.history-list .tag { font-size: 11px; color: #ffa000; margin-left: 6px; }

/* ---------- PIN ---------- */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
    z-index: 10;
}

.pin-box {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    width: 85%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pin-box input {
    font-size: 22px;
    padding: 10px;
    border-radius: 8px;
    border: 2px solid var(--primary-color);
    background: var(--bg-color);
    color: var(--text-color);
    text-align: center;
    letter-spacing: 6px;
}

.pin-msg { color: #e53935; font-size: 13px; min-height: 16px; }
