:root {
    --bg: #fafafa;
    --surface: rgba(0,0,0,0.02);
    --text: #111111;
    --subtle: #888888;
    --button-bg: #8e8e93;
    --button-text: #ffffff;
    --button-hover: #7d7d82;
    --border: rgba(0,0,0,0.08);
    --ring: #f5f5f5;
    --quote-font: 'Playfair Display', Georgia, serif;
    --ui-font: 'Inter', -apple-system, sans-serif;
}

[data-theme="dark"] {
    --bg: #0a0a0a;
    --surface: rgba(255,255,255,0.03);
    --text: #f5f5f5;
    --subtle: #a0a0a0;
    --button-bg: #c0c0c0;
    --button-text: #0a0a0a;
    --button-hover: #d0d0d0;
    --border: rgba(255,255,255,0.08);
    --ring: #111111;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
    font-family: var(--ui-font);
    background: var(--bg);
    color: var(--text);
    transition: background 0.5s ease, color 0.5s ease;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: max(28px, env(safe-area-inset-top));
    padding-bottom: max(28px, env(safe-area-inset-bottom));
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background 0.5s ease, color 0.5s ease;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-content {
    max-width: 420px;
    width: 100%;
    text-align: center;
    animation: fadeInUp 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-content h1 {
    font-family: var(--quote-font);
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.modal-sub {
    color: var(--subtle);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 28px;
}

.instructions {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 24px;
    text-align: left;
    animation: fadeInUp 0.8s 0.1s both cubic-bezier(0.22, 1, 0.36, 1);
}

.instructions p {
    font-size: 0.9rem;
    margin-bottom: 6px;
    color: var(--subtle);
}

.instructions ol {
    padding-left: 20px;
    margin-top: 10px;
}

.instructions li {
    margin-bottom: 10px;
    line-height: 1.5;
    font-size: 0.95rem;
}

.instructions li strong {
    color: var(--text);
    font-weight: 500;
}

.share-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--button-bg);
    color: var(--button-text);
    border-radius: 8px;
    font-size: 14px;
    vertical-align: middle;
    margin: 0 3px;
}

.subtle {
    color: var(--subtle);
    font-size: 0.8rem;
    animation: fadeInUp 0.8s 0.2s both cubic-bezier(0.22, 1, 0.36, 1);
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(var(--bg), 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    line-height: 1;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease, color 0.3s ease;
}

.theme-toggle:hover { transform: scale(1.15) rotate(15deg); }
.theme-toggle:active { transform: scale(0.95); }

.theme-toggle .icon-dark { display: none; }
[data-theme="dark"] .theme-toggle .icon-light { display: none; }
[data-theme="dark"] .theme-toggle .icon-dark { display: inline; }

/* Container */
.container {
    width: 100%;
    max-width: 560px;
    margin-top: 100px;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    position: relative;
    z-index: 1;
}

/* Quote */
.quote-wrapper {
    width: 100%;
    text-align: center;
    position: relative;
}

#quote-box {
    width: 100%;
    min-height: 140px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    font-family: var(--quote-font);
    font-size: 1.75rem;
    line-height: 1.5;
    color: var(--text);
    text-align: center;
    resize: none;
    padding: 24px 12px;
    outline: none;
    transition: border-color 0.4s ease;
    caret-color: transparent;
    user-select: text;
    -webkit-user-select: text;
}

#quote-box::placeholder {
    color: var(--subtle);
    font-style: italic;
    opacity: 0.6;
}

#quote-box:focus { border-color: var(--button-bg); }

.attribution {
    margin-top: 16px;
    font-family: var(--quote-font);
    font-size: 1rem;
    font-style: italic;
    color: var(--subtle);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.attribution.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Generate Button */
.generate-btn {
    position: relative;
    width: 100%;
    max-width: 280px;
    padding: 18px 36px;
    border-radius: 100px;
    border: none;
    background: var(--button-bg);
    color: var(--button-text);
    font-family: var(--ui-font);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease, box-shadow 0.4s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.generate-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}

.generate-btn:active {
    transform: translateY(-1px) scale(0.98);
    transition-duration: 0.1s;
}

[data-theme="dark"] .generate-btn { box-shadow: 0 4px 20px rgba(255,255,255,0.06); }
[data-theme="dark"] .generate-btn:hover { box-shadow: 0 12px 32px rgba(255,255,255,0.1); }

.btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transform: skewX(-20deg);
    transition: none;
    pointer-events: none;
}

.generate-btn:hover .btn-shine {
    animation: shine 0.8s ease;
}

@keyframes shine {
    0% { left: -100%; }
    100% { left: 200%; }
}

/* Scheduler */
.scheduler {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    backdrop-filter: blur(10px);
    transition: border-color 0.4s ease, background 0.4s ease;
}

.scheduler label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--subtle);
    font-weight: 500;
    text-align: center;
}

.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--subtle);
    pointer-events: none;
}

.scheduler select {
    width: 100%;
    padding: 14px 40px 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: var(--ui-font);
    font-size: 0.95rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    appearance: none;
    -webkit-appearance: none;
}

.scheduler select:focus {
    border-color: var(--button-bg);
    box-shadow: 0 0 0 3px rgba(142,142,147,0.15);
}

.notify-btn {
    width: 100%;
    padding: 14px 24px;
    border-radius: 14px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text);
    font-family: var(--ui-font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.notify-btn:hover {
    background: var(--button-bg);
    color: var(--button-text);
    border-color: var(--button-bg);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.notify-btn:active { transform: translateY(0) scale(0.98); }

.notify-btn.active {
    background: var(--button-bg);
    color: var(--button-text);
    border-color: var(--button-bg);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

[data-theme="dark"] .notify-btn:hover { box-shadow: 0 8px 24px rgba(255,255,255,0.08); }

.status {
    font-size: 0.8rem;
    color: var(--subtle);
    text-align: center;
    min-height: 20px;
    font-weight: 400;
    transition: color 0.3s ease;
}

.status.active { color: var(--text); }

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar hide */
#quote-box::-webkit-scrollbar { display: none; }
#quote-box { scrollbar-width: none; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}