/* =============================================
   PadWriter.io — Main Stylesheet
   Aesthetic: Editorial / Refined Warm Minimal
   ============================================= */

:root {
    --bg: #f5f1eb;
    --paper: #faf8f4;
    --ink: #1a1a2e;
    --ink-soft: #3d3a4f;
    --text-muted: #7a7690;
    --accent: #e8b86d;
    --accent-dark: #c99a4e;
    --line: #e2ddd5;
    --header-bg: #1a1a2e;
    --header-text: #f5f1eb;
    --toolbar-bg: #eeeae2;
    --shadow: 0 4px 24px rgba(26,26,46,0.10);
    --radius: 8px;
    --font-display: 'Playfair Display', serif;
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'DM Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- HEADER ---- */
.site-header {
    background: var(--header-bg);
    color: var(--header-text);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0 1.5rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-icon { width: 32px; height: 32px; }

.logo-text {
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: #f5f1eb;
    letter-spacing: -0.02em;
}

.logo-dot { color: var(--accent); }

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.header-nav button {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.14);
    color: var(--header-text);
    padding: 5px 14px;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    letter-spacing: 0.02em;
}

.header-nav button:hover {
    background: rgba(232,184,109,0.22);
    border-color: var(--accent);
    color: var(--accent);
}

#btnAI {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--ink);
    font-weight: 600;
}

#btnAI:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

.save-status {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    flex-shrink: 0;
    font-family: var(--font-mono);
    white-space: nowrap;
}

/* ---- TOOLBAR ---- */
.toolbar {
    background: var(--toolbar-bg);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.tool-btn {
    background: var(--paper);
    border: 1px solid var(--line);
    color: var(--ink-soft);
    padding: 4px 10px;
    border-radius: 5px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.tool-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--ink);
}

.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

select {
    background: var(--paper);
    border: 1px solid var(--line);
    color: var(--ink-soft);
    padding: 4px 8px;
    border-radius: 5px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    cursor: pointer;
}

select:focus { outline: 1px solid var(--accent); }

.stats {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 8px;
}

/* ---- EDITOR ---- */
.editor-wrap {
    flex: 1;
    position: relative;
    max-width: 900px;
    width: 100%;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

.paper-lines {
    position: absolute;
    inset: 0 1.5rem;
    background-image: repeating-linear-gradient(
        transparent,
        transparent 27px,
        #dedad2 28px
    );
    background-position: 0 44px;
    border-radius: var(--radius);
    pointer-events: none;
    opacity: 0.45;
}

#notepad {
    display: block;
    width: 100%;
    min-height: calc(100vh - 300px);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 2rem 2.5rem;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.9;
    color: var(--ink);
    resize: vertical;
    box-shadow: var(--shadow), inset 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s;
    position: relative;
    z-index: 1;
}

#notepad:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent), var(--shadow);
}

#notepad::placeholder { color: #b0aa9e; font-style: italic; }

.editor-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.74rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    padding: 0 0.5rem;
}

.note-id {
    background: var(--toolbar-bg);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--line);
}

/* ---- FEATURES ---- */
.features-section {
    background: var(--paper);
    border-top: 1px solid var(--line);
    padding: 4rem 1.5rem;
}

.features-grid {
    max-width: 960px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.feature-card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.feature-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.f-icon {
    font-size: 1.8rem;
    margin-bottom: 0.75rem;
}

.feature-card h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--ink);
    margin-bottom: 0.4rem;
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--ink-soft);
    line-height: 1.6;
}

/* ---- MODALS ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26,26,46,0.65);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(3px);
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--paper);
    border-radius: 12px;
    padding: 1.75rem;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--ink);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--line);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--ink); }

.ai-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1rem;
}

.ai-chip {
    background: var(--toolbar-bg);
    border: 1px solid var(--line);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    cursor: pointer;
    font-family: var(--font-body);
    color: var(--ink-soft);
    transition: all 0.15s;
}

.ai-chip:hover, .ai-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--ink);
    font-weight: 600;
}

#aiCustomPrompt {
    width: 100%;
    min-height: 80px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--ink);
    resize: vertical;
    margin-bottom: 1rem;
}

#aiCustomPrompt:focus { outline: 1px solid var(--accent); }

.btn-primary {
    background: var(--accent);
    border: none;
    color: var(--ink);
    font-weight: 700;
    font-family: var(--font-body);
    padding: 10px 24px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    width: 100%;
    transition: background 0.2s;
}

.btn-primary:hover { background: var(--accent-dark); color: #fff; }

.ai-result {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    font-size: 0.875rem;
    color: var(--ink-soft);
    display: none;
    white-space: pre-wrap;
}

.ai-result.show { display: block; }

.share-link-wrap {
    display: flex;
    gap: 8px;
}

.share-link-wrap input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 9px 12px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--ink-soft);
}

.share-link-wrap button {
    background: var(--accent);
    border: none;
    color: var(--ink);
    font-weight: 600;
    padding: 9px 18px;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-body);
}

/* ---- FOOTER ---- */
.site-footer {
    background: var(--header-bg);
    color: rgba(245,241,235,0.6);
    padding: 2rem 1.5rem;
    margin-top: auto;
}

.footer-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--header-text);
    font-size: 0.9rem;
}

.logo-icon-sm { width: 24px; height: 24px; }

.footer-links {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: rgba(245,241,235,0.55);
    text-decoration: none;
    font-size: 0.82rem;
    transition: color 0.2s;
}

.footer-links a:hover { color: var(--accent); }

.footer-copy {
    font-size: 0.75rem;
    color: rgba(245,241,235,0.3);
}

/* ---- LEGAL PAGES ---- */
.legal-wrap {
    max-width: 760px;
    margin: 3rem auto;
    padding: 2rem 2rem 4rem;
    background: var(--paper);
    border-radius: 12px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.back-link {
    display: inline-block;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    font-family: var(--font-mono);
}

.back-link:hover { color: var(--accent-dark); }

.legal-wrap h1 {
    font-family: var(--font-display);
    font-size: 2.2rem;
    color: var(--ink);
    margin-bottom: 0.5rem;
}

.legal-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-bottom: 2rem;
}

.legal-wrap h2 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    color: var(--ink);
    margin: 1.75rem 0 0.5rem;
}

.legal-wrap p, .legal-wrap ul {
    font-size: 0.925rem;
    color: var(--ink-soft);
    line-height: 1.75;
    margin-bottom: 0.5rem;
}

.legal-wrap ul { padding-left: 1.4rem; }
.legal-wrap li { margin-bottom: 0.3rem; }
.legal-wrap a { color: var(--accent-dark); }

/* ---- FOCUS MODE ---- */
body.focus-mode .toolbar,
body.focus-mode .site-header .header-nav,
body.focus-mode .features-section,
body.focus-mode .site-footer { display: none !important; }

body.focus-mode .site-header { justify-content: space-between; }

body.focus-mode #notepad {
    min-height: calc(100vh - 120px);
    border-color: transparent;
    box-shadow: none;
}

/* ---- TOAST ---- */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--ink);
    color: var(--header-text);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    z-index: 999;
    box-shadow: var(--shadow);
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s;
}

.toast.show { transform: translateY(0); opacity: 1; }

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
    .site-header { padding: 0 1rem; gap: 0.75rem; }
    .header-nav button { padding: 5px 9px; font-size: 0.75rem; }
    .save-status { display: none; }
    .toolbar { padding: 6px 1rem; }
    .editor-wrap { padding: 0 0.75rem; margin: 1rem auto; }
    #notepad { padding: 1.25rem 1.25rem; font-size: 15px; }
    .features-section { padding: 2.5rem 1rem; }
    .legal-wrap { margin: 1rem; padding: 1.5rem; }
}

@media print {
    .site-header, .toolbar, .editor-meta, .features-section, .site-footer { display: none !important; }
    #notepad { border: none; box-shadow: none; min-height: unset; }
    .editor-wrap { margin: 0; padding: 0; max-width: 100%; }
}
