:root {
    --bg: #0f1115;
    --fg: #e8e8e8;
    --muted: #9aa0a6;
    --accent: #4f8cff;
    --card: #181b22;
    --border: #262a33;
}

html.light {
    --bg: #f5f5f7;
    --fg: #1a1a1a;
    --muted: #6e6e73;
    --accent: #0066cc;
    --card: #ffffff;
    --border: #d2d2d7;
}

.theme-toggle {
    position: fixed;
    top: calc(0.75rem + env(safe-area-inset-top));
    right: calc(0.75rem + env(safe-area-inset-right));
    z-index: 9999;
    background: var(--card);
    border: 2px solid var(--accent);
    border-radius: 8px;
    min-width: 44px;
    min-height: 44px;
    padding: 0.35rem 0.65rem;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    color: var(--fg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.theme-toggle:hover { opacity: 0.85; }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
}

main {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1rem;
    padding-left: calc(1rem + env(safe-area-inset-left));
    padding-right: calc(1rem + env(safe-area-inset-right));
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}

h1 { margin-top: 0; }
h2 { color: var(--muted); font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.05em; }

section { margin-bottom: 2rem; }

.button-grid {
    display: grid;
    gap: 0.75rem;
}

.button-grid.cols-1 { grid-template-columns: 1fr; }
.button-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.button-grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); }
.button-grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); }

@media (max-width: 520px) {
    main { padding-top: 3.5rem; }
    .button-grid { gap: 0.6rem; }
    .btn { padding: 0.85rem 0.75rem; }
    h1 { font-size: 1.6rem; }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--fg);
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    font: inherit;
    touch-action: manipulation;
}

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

summary.btn { list-style: none; display: flex; }
summary.btn::-webkit-details-marker { display: none; }

.note-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
}

.note-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.note-form input, .note-form textarea {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem;
    font: inherit;
    font-size: 16px;
    min-height: 44px;
}

.note-form textarea { min-height: 6rem; resize: vertical; }

.note-form button { align-self: flex-start; }

.notes ul { list-style: none; padding: 0; }
.notes li {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    margin-bottom: 0.5rem;
}
.notes small { color: var(--muted); margin-left: 0.5rem; }
.notes p { margin: 0.25rem 0 0; }
