:root {
    --primary: #2d5a27;
    --primary-hover: #1e3d1a;
    --success: #4a7c42;
    --accent: #8b6914;
    --accent-light: #c9a227;
    --bg: #faf8f5;
    --bg-card: #ffffff;
    --bg-nav: #3d2b1f;
    --bg-input: #f5f2ed;
    --text: #2c2416;
    --text-muted: #7a6f5f;
    --text-light: #a09585;
    --border: #e0d6c8;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(60, 40, 20, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 2rem 2rem;
}

.container-wide {
    max-width: 1200px;
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--success);
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(45, 90, 39, 0.3);
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

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

/* Login Page */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 360px;
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--primary);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 90, 39, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    font-weight: 500;
    transition: background 0.2s;
}

.btn:hover {
    background: var(--primary-hover);
}

.btn-full {
    width: 100%;
}

.error-msg {
    color: #b91c1c;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    text-align: center;
}

/* Navigation */
.nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 2rem;
    background: var(--bg-nav);
    margin-bottom: 1.25rem;
}

.nav-logo {
    width: 24px;
    height: 24px;
    margin-right: 0.5rem;
}

.nav a {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    transition: color 0.2s;
    line-height: 1;
}

.nav a:hover,
.nav a.active {
    color: var(--accent-light);
}

.nav a.nav-right {
    margin-left: auto;
    font-weight: 300;
}

/* Main Page */
.quote-banner {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-style: italic;
    font-size: 0.95rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.25rem 0;
    margin-bottom: 0.35rem;
}


.date-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.links-list {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.link-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border);
}

.link-item:last-child,
.link-item:has(+ .open-all-row) {
    border-bottom: none;
}

.link-name {
    color: var(--primary);
    font-weight: 500;
}

.link-name:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.link-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.check-time {
    font-size: 0.8rem;
    color: var(--text-light);
}

.link-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--success);
    cursor: pointer;
}

.open-all-row {
    text-align: left;
    padding-top: 0.5rem;
}

.open-all {
    font-size: 0.75rem;
    font-style: italic;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.open-all:hover {
    color: var(--primary);
    text-decoration: underline;
}

.story-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.story-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--accent);
}

.story-textarea {
    resize: vertical;
    min-height: 120px;
    background: var(--bg-input);
}

.save-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-light);
    opacity: 0;
    transition: opacity 0.3s;
}

.save-row.show {
    opacity: 1;
}

.save-row.success {
    color: var(--success);
}

.save-checkmark {
    color: var(--success);
    font-weight: bold;
}

.save-time {
    color: var(--text-light);
    margin-left: 0.5rem;
}

/* Diary Page */
.diary-table {
    width: 100%;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.diary-table th,
.diary-table td {
    padding: 0.75rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

/* .diary-table td:nth-child(even) {
    background: rgba(0, 0, 0, 0.03);
} */

.diary-table tr:hover td:nth-child(even) {
    background: rgba(0, 0, 0, 0.06);
}

.diary-table th:first-child,
.diary-table td:first-child {
    text-align: left;
    white-space: nowrap;
    min-width: 120px;
}

.diary-table th {
    background: var(--bg-nav);
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.diary-table tr:last-child td {
    border-bottom: none;
}

.diary-table tr:hover td:nth-child(odd) {
    background: var(--bg-input);
}


.checkmark {
    color: var(--success);
    font-weight: bold;
}

.no-check {
    color: var(--text-light);
}

.task-count {
    color: var(--primary);
    font-weight: 600;
}

.diary-check {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    transition: background 0.15s;
}

.diary-check[data-link-id] {
    cursor: pointer;
}

.diary-check[data-link-id]:hover {
    background: var(--bg-input);
}

.diary-check-bg {
    display: none;
    position: absolute;
    top: 54%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 23px;
    height: 23px;
    background: #fff;
    border-radius: 50%;
}

.diary-check.checked .diary-check-bg {
    display: block;
}

.diary-check-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1rem;
    color: var(--text-light);
    line-height: 1;
}

.diary-check.checked .diary-check-icon {
    font-size: 2.5rem;
    color: #2eb838;
    /* glyph draws below its em-box center; pull up to visually center */
    transform: translate(-50%, calc(-50% - 4px));
}

/* Story Page */
.story-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 80vh;
    overflow-y: auto;
}

.story-entry {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
}

.story-date {
    font-size: 0.875rem;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.story-content {
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* Settings Page */
.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--accent);
}

.links-table {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.link-row, .add-link-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-input);
    border-radius: var(--radius);
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    padding: 0 0.25rem;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.link-name-input {
    flex: 1;
    min-width: 120px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text);
}

.link-url-input {
    flex: 2;
    min-width: 150px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.85rem;
}

.frequency-select, .frequency-day-select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.85rem;
}

.archive-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.archive-btn:hover {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}

.add-link-row {
    background: transparent;
    border: 1px dashed var(--border);
}

/* Settings cog icon */
.settings-cog {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: background 0.2s, transform 0.2s;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 1.25rem;
}

.settings-cog:hover {
    background: var(--bg-input);
    transform: rotate(45deg);
}

/* Tasks */
.tasks-section {
    margin-top: 1.5rem;
}

.task-input-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.task-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
}

.task-input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-add {
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    background: var(--success);
}

.btn-add:hover {
    background: var(--primary);
}

.pending-tasks {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.5rem;
    margin: 0 -0.5rem;
    border-radius: 4px;
    transition: background 0.15s;
}

.task-item:hover {
    background: rgba(0, 0, 0, 0.035);
}

.task-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--success);
    cursor: pointer;
}

.task-title {
    color: var(--text);
    flex: 1;
    font-size: 0.9rem;
    cursor: text;
}

.task-edit-input {
    flex: 0 1 320px;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
}

.task-edit-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Tasks container */
.tasks-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.completed-tasks-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.completed-task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-light);
    padding: 0.25rem 0.5rem;
    margin: 0 -0.5rem;
}

.completed-task-title {
    text-decoration: line-through;
}

.revert-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s, background 0.2s;
}

.completed-task-item:hover .revert-btn {
    opacity: 1;
}

.revert-btn:hover {
    background: var(--border);
    color: var(--text);
}

/* Completed tasks - Story page */
.story-tasks {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
}

.story-task-item {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.2rem 0;
}

.story-task-item::before {
    content: "\2713";
    color: var(--success);
    margin-right: 0.5rem;
    font-size: 0.7rem;
}
