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

:root {
    --bg-0: #08080d;
    --bg-1: #0e0e16;
    --bg-2: #16161f;
    --bg-3: #1d1d2a;
    --txt: #f3f3f7;
    --txt-dim: #8a8a9a;
    --txt-mute: #5a5a6a;
    --accent: #ff7a1a;
    --accent-2: #ffb347;
    --grad: linear-gradient(135deg, #ff5e1a 0%, #ffb347 100%);
    --orange-glow: 0 6px 20px rgba(255, 122, 26, 0.45);
    --danger: #ff4d6d;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}

html, body {
    height: 100%;
    background: var(--bg-0);
    color: var(--txt);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

body {
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(255, 122, 26, 0.20), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(255, 179, 71, 0.12), transparent 60%),
        var(--bg-0);
    min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, button { font-family: inherit; }

/* === Layout === */
.app {
    max-width: 640px;
    margin: 0 auto;
    min-height: 100dvh;
    padding-top: calc(var(--safe-top) + 8px);
    padding-bottom: calc(var(--safe-bottom) + 32px);
    display: flex;
    flex-direction: column;
}

/* === Topbar === */
.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(180deg, rgba(8, 8, 13, 0.92) 70%, rgba(8, 8, 13, 0));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.brand-center { justify-content: center; text-align: center; }

.logo {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    background: var(--grad);
    border-radius: 12px;
    font-size: 18px;
    color: #fff;
    font-weight: 900;
    box-shadow: var(--orange-glow);
}

.topbar h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.counter {
    background: var(--bg-2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--txt-dim);
    font-size: 13px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 999px;
    min-width: 38px;
    text-align: center;
}

.back {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    background: var(--bg-2);
    border-radius: 12px;
    font-size: 24px;
    line-height: 1;
    color: var(--txt-dim);
    font-weight: 600;
    transition: background 0.15s;
}
.back:active { background: var(--bg-3); }

/* === Hero progress (project view) === */
.hero-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 22px 14px;
}
.hero-bar .bar { flex: 1; height: 8px; }
.hero-pct {
    font-size: 13px;
    font-weight: 700;
    color: var(--txt-dim);
    min-width: 38px;
    text-align: right;
}

/* === Content === */
.content {
    padding: 8px 22px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* === Add form === */
.add-form {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-1);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    padding: 8px 8px 8px 18px;
    box-shadow: var(--shadow);
    transition: border-color 0.18s, transform 0.1s;
}
.add-form:focus-within {
    border-color: rgba(255, 122, 26, 0.6);
    box-shadow: 0 10px 30px rgba(255, 122, 26, 0.22);
}
.add-form input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--txt);
    font-size: 16px;
    padding: 14px 0;
    font-weight: 500;
}
.add-form input::placeholder { color: var(--txt-mute); }

.add-form button {
    width: 46px; height: 46px;
    border-radius: 14px;
    background: var(--grad);
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    display: grid; place-items: center;
    transition: transform 0.12s, box-shadow 0.12s;
    box-shadow: var(--orange-glow);
}
.add-form button:active { transform: scale(0.94); }

/* === Search === */
.search {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-1);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 0 12px;
    transition: border-color 0.18s;
}
.search:focus-within {
    border-color: rgba(255, 122, 26, 0.45);
}
.search-icon {
    color: var(--txt-mute);
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}
.search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--txt);
    font-size: 15px;
    padding: 12px 8px;
    -webkit-appearance: none;
    appearance: none;
}
.search input::placeholder { color: var(--txt-mute); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
    width: 26px; height: 26px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--bg-3);
    color: var(--txt-dim);
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    transition: background 0.15s;
}
.search-clear:active { background: rgba(255, 255, 255, 0.12); }
.search-clear[hidden] { display: none; }

.no-results {
    text-align: center;
    color: var(--txt-mute);
    font-size: 14px;
    padding: 20px 0 0;
}

/* === Empty state === */
.empty {
    text-align: center;
    padding: 60px 20px 40px;
    color: var(--txt-mute);
}
.empty-icon {
    font-size: 56px;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 12px;
    line-height: 1;
}
.empty p { font-size: 15px; line-height: 1.6; }

/* === Project cards === */
.cards { list-style: none; display: flex; flex-direction: column; gap: 12px; }

.card {
    position: relative;
    background: var(--bg-1);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.12s, border-color 0.18s;
}
.card:active { transform: scale(0.985); }

.card-link {
    display: block;
    padding: 18px 56px 16px 20px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.card-head h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    word-break: break-word;
}
.chev {
    color: var(--txt-mute);
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}

.meta {
    display: flex;
    justify-content: space-between;
    color: var(--txt-dim);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
}
.pct {
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 800;
}

.bar {
    width: 100%;
    height: 6px;
    background: var(--bg-3);
    border-radius: 999px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background: var(--grad);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* Delete button on cards */
.card .del-form {
    position: absolute;
    top: 12px;
    right: 12px;
}
.card .del-form button {
    width: 32px; height: 32px;
    border-radius: 10px;
    background: rgba(255, 77, 109, 0.08);
    color: var(--danger);
    font-size: 13px;
    font-weight: 700;
    display: grid; place-items: center;
    transition: background 0.15s;
}
.card .del-form button:active { background: rgba(255, 77, 109, 0.2); }

/* === Toggle view button === */
.task-actions {
    display: flex;
    gap: 10px;
    align-items: stretch;
}
.toggle-view {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: 14px;
    background: var(--bg-1);
    border: 1px solid rgba(255, 122, 26, 0.25);
    color: var(--accent-2);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.01em;
    transition: background 0.18s, border-color 0.18s, transform 0.1s, box-shadow 0.18s, color 0.18s;
}
.toggle-view:active { transform: scale(0.98); }
.toggle-view.is-done-mode {
    background: var(--grad);
    border-color: transparent;
    color: #fff;
    box-shadow: var(--orange-glow);
}
.toggle-count {
    background: rgba(255, 122, 26, 0.15);
    color: var(--accent-2);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.3;
    min-width: 28px;
    text-align: center;
}
.toggle-view.is-done-mode .toggle-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.complete-all {
    padding: 0 18px;
    border-radius: 14px;
    background: var(--grad);
    border: none;
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--orange-glow);
    transition: transform 0.1s, box-shadow 0.18s, opacity 0.18s;
}
.complete-all:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
    background: var(--bg-3);
}
.complete-all:not(:disabled):active { transform: scale(0.94); }

/* === Tasks === */
.tasks { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.tasks[data-filter="pending"] .task.is-done { display: none !important; }
.tasks[data-filter="done"] .task:not(.is-done) { display: none !important; }

.task {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-1);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    padding: 14px 16px;
    transition: transform 0.12s, opacity 0.18s;
}
.task:active { transform: scale(0.99); }

.toggle-form { display: contents; }
.check {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid var(--bg-3);
    display: grid; place-items: center;
    font-size: 14px;
    color: #0a0a0f;
    font-weight: 800;
    flex-shrink: 0;
    transition: all 0.18s;
}
.task.is-done .check {
    background: var(--grad);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 122, 26, 0.4);
}

.task-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.task-title {
    font-size: 16px;
    font-weight: 500;
    word-break: break-word;
    transition: color 0.18s;
}
.task.is-done .task-title {
    color: var(--txt-mute);
    text-decoration: line-through;
    text-decoration-color: var(--txt-mute);
}
.task-done-at {
    font-size: 11px;
    color: var(--txt-mute);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.task .del-form button {
    width: 32px; height: 32px;
    border-radius: 10px;
    background: rgba(255, 77, 109, 0.08);
    color: var(--danger);
    font-size: 13px;
    font-weight: 700;
    display: grid; place-items: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.task .del-form button:active { background: rgba(255, 77, 109, 0.2); }

/* === Export === */
.export {
    background: var(--bg-1);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 6px;
}
.export > summary {
    list-style: none;
    cursor: pointer;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--txt-dim);
    user-select: none;
}
.export > summary::-webkit-details-marker { display: none; }
.export-chev {
    color: var(--txt-mute);
    font-size: 14px;
    transition: transform 0.2s;
}
.export[open] .export-chev { transform: rotate(180deg); }

.export-body {
    padding: 0 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.export-body textarea {
    width: 100%;
    min-height: 140px;
    max-height: 50vh;
    background: var(--bg-0);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    color: var(--txt);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 14px;
    line-height: 1.55;
    padding: 14px;
    resize: vertical;
    outline: none;
    transition: border-color 0.18s;
}
.export-body textarea:focus {
    border-color: rgba(255, 122, 26, 0.5);
}
.copy-btn {
    align-self: flex-end;
    padding: 10px 18px;
    border-radius: 12px;
    background: var(--bg-3);
    color: var(--txt);
    font-size: 14px;
    font-weight: 700;
    transition: background 0.18s, transform 0.1s, color 0.18s;
}
.copy-btn:active { transform: scale(0.96); }
.copy-btn.is-ok {
    background: var(--grad);
    color: #fff;
    box-shadow: var(--orange-glow);
}

/* === Report button === */
.report-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 18px;
    border-radius: var(--radius);
    background: var(--bg-1);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--txt);
    font-size: 14px;
    font-weight: 700;
    transition: border-color 0.18s, transform 0.1s;
}
.report-btn:active { transform: scale(0.99); }
.report-btn:hover { border-color: rgba(255, 122, 26, 0.4); }
.report-icon {
    width: 30px; height: 30px;
    display: grid; place-items: center;
    background: var(--grad);
    color: #fff;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 800;
    box-shadow: var(--orange-glow);
}

/* === Mail block === */
.mail-form {
    padding: 0 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.mail-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--txt-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.mail-label select,
.mail-label input {
    background: var(--bg-0);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    color: var(--txt);
    font-size: 15px;
    padding: 12px 14px;
    outline: none;
    transition: border-color 0.18s;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 500;
    appearance: none;
    -webkit-appearance: none;
}
.mail-label select {
    background-image: linear-gradient(45deg, transparent 50%, var(--txt-dim) 50%),
                      linear-gradient(135deg, var(--txt-dim) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 32px;
}
.mail-label select:focus,
.mail-label input:focus {
    border-color: rgba(255, 122, 26, 0.5);
}
.mail-btn {
    align-self: stretch;
    padding: 13px 18px;
    border-radius: 12px;
    background: var(--grad);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    box-shadow: var(--orange-glow);
    transition: transform 0.1s;
}
.mail-btn:active { transform: scale(0.98); }

/* === Flash === */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    border: 1px solid transparent;
}
.flash-ok {
    background: rgba(26, 164, 107, 0.12);
    color: #5fd6a0;
    border-color: rgba(26, 164, 107, 0.3);
}
.flash-fail,
.flash-err {
    background: rgba(255, 77, 109, 0.10);
    color: #ff8aa0;
    border-color: rgba(255, 77, 109, 0.3);
}
.flash-empty {
    background: rgba(255, 179, 71, 0.10);
    color: var(--accent-2);
    border-color: rgba(255, 179, 71, 0.3);
}

/* === Animations === */
@keyframes pop {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.card, .task { animation: pop 0.25s ease both; }

/* === Larger screens === */
@media (min-width: 720px) {
    .topbar h1 { font-size: 26px; }
    .card-head h2 { font-size: 20px; }
}
