/**
 * GTD App - Inspired by Morning Pages
 */

:root {
    --background: #ffffff;
    --foreground: #292931;
    --muted: #f5f5f5;
    --muted-foreground: #737373;
    --accent: #FFF6A9;
    --accent-foreground: #000000;
    --border: #e5e5e5;
    --card-shadow: 0 7px 44px -10px rgba(104, 106, 172, 0.3);
    --button-hover-shadow: 0 0 0 2px #FFF6A9;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--foreground);
    min-height: 100vh;
    line-height: 1.6;
}

a {
    color: inherit;
    text-decoration: none;
}

footer a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

#app {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    margin-bottom: 0;
}

.header-row-brand {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 48px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--foreground);
    text-decoration: none;
    background: var(--accent);
    padding: 4px 10px;
    border-radius: 6px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-dot {
    color: var(--muted-foreground);
    opacity: 0.5;
    font-size: 13px;
}

.save-status {
    font-size: 13px;
    color: var(--muted-foreground);
    margin-right: 10px;
}

.save-status:empty {
    margin-right: 0;
}

.save-status.saving {
    color: var(--foreground);
}

.save-status.error {
    color: #dc2626;
}

.header-link {
    font-size: 13px;
    color: var(--muted-foreground);
    text-decoration: none;
    transition: color 0.2s;
}

.header-link:hover {
    color: var(--foreground);
}

.header-link-logout {
    margin-left: 10px;
}

.header-row-section {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0 40px;
    margin-bottom: 36px;
}

.week-number {
    font-size: 14px;
    font-weight: 700;
    color: var(--foreground);
}

/* Main */
main {
    flex: 1;
    padding: 0 40px;
}

/* Section Nav */
.section-nav {
    display: flex;
    gap: 24px;
}

.section-btn {
    font-family: inherit;
    font-size: 28px;
    font-weight: 400;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-foreground);
    transition: color 0.2s;
    padding: 0;
}

.section-btn:hover {
    color: var(--foreground);
    opacity: 0.7;
}

.section-btn.active {
    color: var(--foreground);
    font-weight: 700;
}

/* Sections */
.section {
    display: none;
}

.section.active {
    display: block;
}

/* Tabs */
.tabs {
    display: flex;
    align-items: baseline;
    gap: 24px;
    margin-bottom: 24px;
}

.tab {
    font-family: inherit;
    font-size: 14px;
    font-weight: 400;
    padding: 8px 0;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    color: var(--muted-foreground);
    transition: color 0.2s;
}

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

.tab.active {
    color: var(--foreground);
    font-weight: 600;
    border-bottom-color: var(--foreground);
}

.tabs-date {
    margin-left: auto;
    font-size: 12px;
    color: #b3b3b3;
    white-space: nowrap;
}

/* Content Area */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Editor Wrapper */
.editor-wrapper {
    position: relative;
    min-height: 200px;
}

/* Editor */
.editor {
    width: 100%;
    min-height: 120px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.8;
    padding: 0;
    border: none;
    resize: none;
    background: transparent;
    outline: none;
    color: var(--foreground);
}

.editor.hidden {
    display: none;
}

.editor::placeholder {
    color: var(--muted-foreground);
}

/* Rendered Preview (shown when not editing) */
.rendered-preview {
    display: none;
    font-size: 15px;
    line-height: 1.8;
    min-height: 200px;
    cursor: text;
}

.rendered-preview.visible {
    display: block;
}

.rendered-preview p {
    margin-bottom: 1em;
}

.rendered-preview h1, .rendered-preview h2, .rendered-preview h3 {
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.rendered-preview h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted-foreground);
}

.rendered-preview ul, .rendered-preview ol {
    margin-left: 1.5em;
    margin-bottom: 1em;
}

.rendered-preview li {
    margin-bottom: 0.15em;
}

.rendered-preview del {
    color: var(--muted-foreground);
    text-decoration: line-through;
}

.rendered-preview mark {
    background: var(--accent);
    padding: 0 4px;
    border-radius: 2px;
}

.rendered-preview a {
    color: var(--foreground);
}

.rendered-preview code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.9em;
    background: var(--muted);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Rendered Content */
.rendered {
    font-size: 15px;
    line-height: 1.8;
    min-height: 200px;
}

.rendered p {
    margin-bottom: 1em;
}

.rendered h1, .rendered h2, .rendered h3 {
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.rendered h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted-foreground);
}

.rendered ul, .rendered ol {
    margin-left: 1.5em;
    margin-bottom: 1em;
}

.rendered li {
    margin-bottom: 0.15em;
}

.rendered li.task-item.done,
.rendered-preview li.task-item.done {
    text-decoration: line-through;
    color: var(--muted-foreground);
}

.rendered del {
    color: var(--muted-foreground);
    text-decoration: line-through;
}

.rendered mark {
    background: var(--accent);
    padding: 0 4px;
    border-radius: 2px;
}

.rendered a {
    color: var(--foreground);
}

.rendered code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.9em;
    background: var(--muted);
    padding: 2px 6px;
    border-radius: 4px;
}

.empty {
    color: var(--muted-foreground);
}

/* Section Footer */
.section-footer {
    margin-top: 16px;
}

.meta {
    font-size: 14px;
    color: var(--muted-foreground);
}

.meta strong {
    font-weight: 600;
    color: var(--foreground);
}

/* Footer */
footer {
    margin-top: auto;
    padding: 48px 40px 0;
    text-align: center;
}

footer p {
    font-size: 13px;
    color: var(--muted-foreground);
}

/* Desktop: wider content area */
@media (min-width: 1024px) {
    #app {
        max-width: 1100px;
    }
}

/* Responsive */
@media (max-width: 600px) {
    #app {
        padding: 16px;
    }

    .header-row-brand {
        margin-bottom: 32px;
    }

    .header-row-section {
        padding: 0;
        margin-bottom: 24px;
    }

    main {
        padding: 0;
    }

    .header-dot,
    .tabs-date {
        display: none;
    }

    .header-nav {
        gap: 10px;
    }

    .header-link-logout {
        margin-left: 4px;
    }

    .save-status {
        font-size: 12px;
    }

    .section-btn {
        font-size: 22px;
    }

    .tabs {
        gap: 0;
        justify-content: space-between;
    }

    .tab {
        font-size: 13px;
        padding: 8px 0;
        flex: 1;
        text-align: center;
    }

    .editor {
        min-height: 300px;
    }
}
