:root {
    --bg: #0e0c0a;
    --ink: #e8dcc8;
    --ink-dim: #7a6e60;
    --accent: #c9a96e;
    --accent-glow: rgba(201, 169, 110, 0.15);
    --syn-bg: #141210;
    --highlight: #c9a96e22;
    --border: #2e2820;
  }

  [data-theme="light"] {
    --bg: #f5f0e8;
    --ink: #2a2018;
    --ink-dim: #8a7a68;
    --accent: #a07840;
    --accent-glow: rgba(160, 120, 64, 0.12);
    --syn-bg: #ede8df;
    --highlight: #a0784022;
    --border: #d4c8b8;
  }

  body {
    transition: background 0.3s ease, color 0.3s ease;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'DM Mono', monospace;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }
  header {
    padding: 1.5rem 2.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }
  header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    color: var(--accent);
  }
  header span {
    font-size: 0.7rem;
    color: var(--ink-dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
  .workspace {
    display: grid;
    grid-template-columns: 1fr 280px;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 60px);
  }
  .editor-pane {
    padding: 3rem 3rem 2rem;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
  }
  .word-count {
    font-size: 0.65rem;
    color: var(--ink-dim);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
  }

.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.editor-toolbar .word-count {
    margin-bottom: 0;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--ink-dim);
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.copy-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.copy-btn.copied {
    border-color: var(--accent);
    color: var(--accent);
}

  #editor {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: var(--ink);
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    line-height: 1.9;
    caret-color: var(--accent);
    min-height: 300px;
  }
  #editor::placeholder { color: var(--ink-dim); font-style: italic; }
  .active-word-display {
    margin-top: 1.5rem;
    padding: 0.6rem 1rem;
    background: var(--highlight);
    border-left: 2px solid var(--accent);
    font-size: 0.75rem;
    color: var(--ink-dim);
    display: none;
  }
  .active-word-display strong {
    color: var(--accent);
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    font-style: italic;
    font-weight: 400;
  }
  .syn-pane {
    background: var(--syn-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .syn-header {
    padding: 1.2rem 1.4rem 1rem;
    border-bottom: 1px solid var(--border);
  }
  .syn-header p {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--ink-dim);
    margin-bottom: 0.25rem;
  }
  .syn-header .current-word {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    font-style: italic;
    color: var(--accent);
    min-height: 1.4rem;
  }
  .syn-list {
    padding: 1rem 0;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  .syn-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid transparent;
    }

.syn-item:hover {
    background: var(--accent-glow);
    border-bottom-color: var(--border);
}

.syn-color {
    width: 3px;
    align-self: stretch;
    flex-shrink: 0;
    opacity: 0.5;
}

.syn-item:hover .syn-color {
    opacity: 1;
}

.syn-word {
    padding: 0.7rem 1.2rem;
    font-size: 0.82rem;
    color: var(--ink);
    flex: 1;
}

.syn-item:hover .syn-word {
    color: #fff;
}

.syn-hint {
    font-size: 0.6rem;
    color: var(--ink-dim);
    padding-right: 1rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.syn-item:hover .syn-hint {
    opacity: 1;
}

.syn-empty {
    padding: 2rem 1.4rem;
    font-size: 0.72rem;
    color: var(--ink-dim);
    line-height: 1.7;
    font-style: italic;
}

.syn-loading {
    padding: 1.5rem 1.4rem;
    display: flex;
    gap: 4px;
    align-items: center;
}

.dot {
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 1.2s ease-in-out infinite;
}

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

@keyframes pulse {
    0%, 100% { opacity: 0.2; transform: scale(1); }
    50%       { opacity: 1;   transform: scale(1.3); }
}

.tip {
    padding: 0.8rem 1.4rem;
    border-top: 1px solid var(--border);
    font-size: 0.6rem;
    color: var(--ink-dim);
    line-height: 1.6;
}

.tip span {
    background: var(--border);
    padding: 0.1rem 0.4rem;
    font-size: 0.58rem;
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--accent);
    color: #0e0c0a;
    padding: 0.5rem 1.2rem;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 640px) {
    .toast {
        bottom: auto;
        top: 4.5rem;
    }
}


/* ─── celular ─── */
@media (max-width: 640px) {
    header {
        padding: 1rem;
        flex-direction: column;
        align-items: center;
        text-align: center;
        position: relative;
        padding-left: 3.5rem;
    }

    .workspace {
        display: flex; 
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    .editor-pane {
        flex: 1;
        padding: 1rem;
        border-right: none;
        border-bottom: 2px solid var(--border);
        display: flex;
        flex-direction: column;
    }

    #editor {
        flex-grow: 1;
        font-size: 16px; 
        min-height: 200px;
    }

    .syn-pane {
        width: 100%;
        height: 45vh; 
        background: var(--syn-bg);
        box-shadow: 0 -8px 16px rgba(0,0,0,0.1);
        z-index: 10;
    }

    .syn-header {
        padding: 0.8rem 1.2rem;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
    }

    .syn-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.6rem;
        padding: 1rem;
        overflow-y: auto;
        height: calc(100% - 60px);
    }

    .syn-item {
        padding: 1rem;
        text-align: center;
        border: 1px solid var(--border);
        background: var(--bg);
        border-radius: 4px;
    }

    .syn-hint {
        display: none;
    }

    .word-count {
        font-size: 0.7rem;
        margin-bottom: 0.5rem;
    }
}

.main-footer {
    padding: 1rem;
    text-align: center;
    background: var(--bg);
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--ink-dim);
}

.main-footer strong {
    color: var(--accent);
    font-weight: 400;
}

.main-footer a {
    color: var(--ink-dim);
    text-decoration: none;
    transition: color 0.3s ease;
}

.main-footer a:hover {
    color: var(--accent);
    text-decoration: underline;
}


@media (max-width: 640px) {
    .main-footer {
        padding: 0.8rem;
        background: var(--syn-bg);
    }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem; 
}

.support-message {
    font-size: 0.65rem;
    color: var(--ink-dim);
    max-width: 200px; 
    text-align: right;
    line-height: 1.4;
    letter-spacing: 0.02rem;
}

.support-message strong {
    color: var(--accent);
    font-weight: normal;
}

.donate-btn {
    padding: 0.5rem 1.2rem;
    border: 1px solid var(--accent);
    color: var(--accent);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: bold;
    letter-spacing: 0.1rem;
    border-radius: 2px;
    white-space: nowrap;
}

/* donaciones: visible en escritorio, oculto en celu */
.header-actions { display: flex; }
.donate-mobile  { display: none !important; }

@media (max-width: 640px) {
    header {
        flex-direction: column;
        text-align: center;
        padding: 1.2rem;
        gap: 1rem;
    }

    .header-actions {
        display: none; /* se oculta en celu */
    }

    .support-message {
        text-align: center;
        max-width: 100%;
    }
}

.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--ink-dim);
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 2px;
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.theme-toggle svg {
    width: 14px;
    height: 14px;
    transition: opacity 0.2s ease, transform 0.3s ease;
}

@media (max-width: 640px) {
    .theme-toggle {
        position: absolute;
        top: 1rem;
        right: 1rem;
    }
    header {
        position: relative;
    }
}

/* ─── menú hamburguesa (solo móvil) ─── */
.mobile-menu-toggle {
    display: none;
}

@media (max-width: 640px) {
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        width: 18px;
        height: 15px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        gap: 3px;
        position: absolute;
        top: 1.2rem;
        left: 1rem;
        z-index: 100;
    }

    .mobile-menu-toggle span {
        width: 18px;
        height: 1.5px;
        background: var(--accent);
        border-radius: 1px;
        transition: all 0.3s ease;
        display: block;
    }

    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(8px, 8px);
    }

    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(8px, -8px);
    }
}

/* overlay del menú */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (max-width: 640px) {
    .mobile-menu-overlay.active {
        display: block;
        opacity: 1;
    }
}

/* menú lateral */
.mobile-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    z-index: 100;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.3);
}

@media (max-width: 640px) {
    .mobile-menu {
        display: flex;
    }

    .mobile-menu.active {
        transform: translateX(0);
    }
}

.mobile-menu-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

.mobile-menu-close {
    background: transparent;
    border: none;
    color: var(--ink);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.mobile-menu-close:hover {
    color: var(--accent);
}

.mobile-menu-content {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.mobile-theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--accent-glow);
    border: 1px solid var(--border);
    border-radius: 4px;
    gap: 1rem;
}

.mobile-theme-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-dim);
    font-weight: 500;
}

.mobile-theme-btn {
    background: transparent;
    border: none;
    color: var(--ink-dim);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mobile-theme-btn:hover {
    color: var(--accent);
}

.mobile-theme-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

/* ─── escritorio: solo la lista de sinónimos hace scroll, no la página ─── */
@media (min-width: 641px) {
    body {
        height: 100vh;
        height: 100dvh;
    }

    .workspace {
        height: auto;
        min-height: 0;
        grid-template-rows: minmax(0, 1fr);
    }

    .editor-pane,
    .syn-pane,
    .syn-list {
        min-height: 0;
    }
}

/* ─── aclaración en el panel de sinónimos ─── */
.tip-note {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px dashed var(--border);
    line-height: 1.6;
}

.tip-note em {
    color: var(--accent);
    font-style: italic;
}

/* ─── créditos del diccionario ─── */
.main-footer .credits {
    margin-top: 0.4rem;
    font-size: 0.65rem;
    line-height: 1.5;
}
