:root {
    --font-heading: 'Cormorant Garamond', 'Georgia', serif;
    --font-body: 'Lora', 'Georgia', serif;

    --color-bg: #f5f0e8;
    --color-text: #2c2418;
    --color-text-secondary: #5c5245;
    --color-text-muted: #8a8070;
    --color-text-ghost: #b5ad9f;
    --color-accent: #8b3a3a;
    --color-accent-hover: #6e2d2d;
    --color-border: #d4cbbf;
    --color-error: #9e3030;
    --color-success: #3d6b4f;
}

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

::selection {
    background: rgba(139, 58, 58, 0.15);
    color: var(--color-text);
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.7;
    min-height: 100vh;
    font-size: 1rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

main {
    max-width: 600px;
    margin: 0 auto;
    padding: 3rem 1.5rem 4rem;
}

h1 {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--color-text);
    letter-spacing: 0.01em;
}

h2 {
    font-family: var(--font-heading);
    font-weight: 400;
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    color: var(--color-text-secondary);
    letter-spacing: 0.01em;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.75rem 0.25rem;
    border: none;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.85;
    resize: vertical;
    background: transparent;
    color: var(--color-text);
    transition: border-color 0.2s;
}

textarea::placeholder {
    color: var(--color-text-ghost);
    font-style: italic;
}

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

button {
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--color-accent);
    border: none;
    border-radius: 0;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-style: italic;
    font-weight: 400;
    cursor: pointer;
    transition: color 0.2s;
    letter-spacing: 0.02em;
}

button:hover {
    color: var(--color-accent-hover);
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

textarea:focus-visible {
    outline: none;
    border-bottom-color: var(--color-accent);
}

button:disabled {
    color: var(--color-text-ghost);
    cursor: not-allowed;
}

button:disabled:hover {
    color: var(--color-text-ghost);
}

/* Page layout */
.page-layout {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

/* Add section */
.add-section {
    padding: 0;
}

.add-section h2 {
    font-weight: 300;
    font-size: 1.75rem;
    color: var(--color-text);
    margin-bottom: 0;
}

.add-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
}

.add-header input[type="date"] {
    width: auto;
    padding: 0.25rem 0.5rem;
    font-family: var(--font-heading);
    font-size: 0.875rem;
    font-style: italic;
    color: var(--color-text-muted);
    border: none;
    background: transparent;
    cursor: pointer;
}

.add-header input[type="date"]:focus {
    box-shadow: none;
    border: none;
    outline: none;
    color: var(--color-text-secondary);
}

input[type="date"] {
    width: 100%;
    padding: 0.75rem 0.25rem;
    border: none;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    font-family: var(--font-heading);
    font-size: 1rem;
    background: transparent;
    color: var(--color-text);
}

input[type="date"]:focus {
    outline: none;
    border-bottom-color: var(--color-accent);
    box-shadow: none;
}

/* Character counter */
.textarea-wrapper {
    position: relative;
}

.char-counter {
    position: absolute;
    bottom: 0.625rem;
    right: 0.25rem;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-style: italic;
    color: var(--color-text-ghost);
    pointer-events: none;
}

.char-counter.near-limit {
    color: #b8860b;
}

.char-counter.over-limit {
    color: var(--color-error);
    font-weight: 600;
    font-style: normal;
}

/* Date navigation */
.date-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.date-nav a {
    font-family: var(--font-heading);
    font-size: 0.875rem;
    font-style: italic;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color 0.2s;
    padding: 0.25rem 0;
}

.date-nav a:hover {
    color: var(--color-accent);
}

.date-nav a:nth-child(2) {
    font-variant: small-caps;
    font-style: normal;
    font-size: 0.9375rem;
    letter-spacing: 0.05em;
}

.date-nav .disabled {
    color: var(--color-text-ghost);
}

/* Year section */
.year-section {
    margin-top: 0;
}

.year-section + .year-section {
    margin-top: 2.5rem;
}

.year-section h2 {
    font-weight: 300;
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

/* Accomplishments */
.accomplishments {
    list-style: none;
}

.accomplishments li {
    padding: 0.75rem 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.accomplishments .text {
    flex: 1;
    line-height: 1.85;
}

.accomplishments .time {
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-style: italic;
    color: var(--color-text-ghost);
    white-space: nowrap;
    padding-top: 0.2rem;
}

.empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2.5rem 1rem;
    font-style: italic;
}

/* Editable text */
.text[data-editable="true"] {
    cursor: pointer;
    padding: 0.25rem 0;
    margin: -0.25rem 0;
    transition: color 0.2s;
}

.text[data-editable="true"]:hover {
    color: var(--color-text-secondary);
}

/* Inline editing */
.inline-edit-form {
    flex: 1;
}

.inline-edit-wrapper {
    position: relative;
}

.inline-edit-textarea {
    width: 100%;
    min-height: 60px;
    padding: 0.5rem 0.25rem;
    padding-right: 3rem;
    border: none;
    border-bottom: 1px solid var(--color-accent);
    border-radius: 0;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.85;
    resize: vertical;
    background: transparent;
    color: var(--color-text);
}

.inline-edit-textarea:focus {
    outline: none;
    box-shadow: none;
}

.inline-counter {
    position: absolute;
    bottom: 0.5rem;
    right: 0.25rem;
}

.inline-edit-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.inline-save-btn,
.inline-cancel-btn {
    padding: 0.25rem 0;
    font-family: var(--font-heading);
    font-size: 0.9375rem;
    font-style: italic;
    background: transparent;
    border: none;
    cursor: pointer;
}

.inline-save-btn {
    color: var(--color-accent);
}

.inline-save-btn:hover {
    color: var(--color-accent-hover);
}

.inline-cancel-btn {
    color: var(--color-text-muted);
}

.inline-cancel-btn:hover {
    color: var(--color-text-secondary);
    background: transparent;
}

/* Delete button */
.delete-btn {
    opacity: 0;
    background: transparent;
    border: none;
    color: var(--color-text-ghost);
    cursor: pointer;
    padding: 0.25rem;
    transition: opacity 0.2s, color 0.2s;
    flex-shrink: 0;
    font-style: normal;
}

.accomplishments li:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    background: transparent;
    color: var(--color-error);
}

.delete-btn.hidden {
    display: none;
}

/* Login */
.auth-container {
    max-width: 340px;
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 80vh;
}

.auth-container h1 {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: 2.75rem;
    text-align: center;
    margin-bottom: 3rem;
    color: var(--color-text);
    letter-spacing: 0.02em;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.form-group input {
    width: 100%;
    padding: 0.625rem 0.25rem;
    border: none;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    font-family: var(--font-body);
    font-size: 1rem;
    background: transparent;
    color: var(--color-text);
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-bottom-color: var(--color-accent);
    box-shadow: none;
}

.auth-form button[type="submit"] {
    width: 100%;
    padding: 0.75rem 1.5rem;
    margin-top: 0.75rem;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-style: normal;
    font-weight: 400;
    letter-spacing: 0.05em;
    color: var(--color-accent);
    background: transparent;
    border: 1px solid var(--color-accent);
    cursor: pointer;
    transition: background 0.3s, color 0.3s;
}

.auth-form button[type="submit"]:hover {
    background: var(--color-accent);
    color: var(--color-bg);
}

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 0;
    font-size: 0.9375rem;
    border-left: 3px solid;
}

.flash-error {
    background: rgba(158, 48, 48, 0.05);
    color: var(--color-error);
    border-left-color: var(--color-error);
    border-top: none;
    border-right: none;
    border-bottom: none;
}

.flash-success {
    background: rgba(61, 107, 79, 0.05);
    color: var(--color-success);
    border-left-color: var(--color-success);
    border-top: none;
    border-right: none;
    border-bottom: none;
}

/* Footer */
.site-footer {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
    text-align: center;
}

.logout-link {
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-style: italic;
    color: var(--color-text-ghost);
    text-decoration: none;
    transition: color 0.2s;
}

.logout-link:hover {
    color: var(--color-text-muted);
}

/* Mobile */
@media (max-width: 480px) {
    main {
        padding: 2rem 1.25rem 3rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .add-section h2 {
        font-size: 1.5rem;
    }

    .auth-container h1 {
        font-size: 2.25rem;
    }

    .accomplishments li {
        flex-direction: column;
        gap: 0.375rem;
    }

    .accomplishments .time {
        align-self: flex-end;
    }

    .delete-btn {
        opacity: 0.6;
    }

    .site-footer {
        padding: 0 1.25rem 2rem;
    }
}
