:root {
    color-scheme: light;
    --background: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #eef2f5;
    --text: #17202a;
    --muted: #68727d;
    --border: #d9e0e6;
    --accent: #2156d8;
    --accent-dark: #173e9e;
    --success: #16803a;
    --success-soft: rgba(30, 167, 79, 0.15);
    --danger: #b42318;
    --shadow: 0 12px 30px rgba(20, 32, 48, 0.08);
    font-family:
        Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--background);
}

body {
    min-height: 100%;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(33, 86, 216, 0.08), transparent 34rem),
        var(--background);
}

button,
a {
    font: inherit;
}

a {
    color: inherit;
}

.site-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 52px 0 72px;
}

.page-header {
    margin-bottom: 30px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1.05;
    letter-spacing: -0.045em;
}

.intro {
    max-width: 680px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.65;
}

.phase-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
}

.phase-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 18px;
    align-items: center;
    min-height: 150px;
    padding: 24px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-decoration: none;
    transition:
        transform 160ms ease,
        border-color 160ms ease,
        box-shadow 160ms ease;
}

.phase-card:hover,
.phase-card:focus-visible {
    border-color: rgba(33, 86, 216, 0.55);
    box-shadow: 0 16px 36px rgba(20, 32, 48, 0.13);
    transform: translateY(-2px);
}

.phase-card:focus-visible,
.back-link:focus-visible,
.task-toggle:focus-visible {
    outline: 3px solid rgba(33, 86, 216, 0.3);
    outline-offset: 3px;
}

.phase-number {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    border-radius: 15px;
    color: var(--accent);
    background: rgba(33, 86, 216, 0.1);
    font-size: 1.35rem;
    font-weight: 850;
}

.phase-card-content {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.phase-name {
    margin-bottom: 7px;
    font-size: 1.2rem;
    font-weight: 800;
}

.remaining-count {
    font-weight: 700;
}

.completion-count {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.9rem;
}

.phase-arrow {
    color: var(--accent);
    font-size: 1.5rem;
}

.progress-track {
    display: block;
    width: 100%;
    height: 8px;
    margin-top: 15px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-soft);
}

.progress-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--success);
    transition: width 220ms ease;
}

.storage-note {
    margin: 26px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

code {
    padding: 0.12rem 0.35rem;
    border-radius: 5px;
    background: rgba(23, 32, 42, 0.06);
}

.top-nav {
    margin-bottom: 26px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 2px;
    color: var(--accent);
    font-weight: 750;
    text-decoration: none;
}

.back-link:hover {
    color: var(--accent-dark);
    text-decoration: underline;
}

.phase-header {
    margin-bottom: 20px;
}

.phase-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: baseline;
}

.phase-remaining {
    font-size: 1.05rem;
}

.phase-complete {
    color: var(--muted);
}

.phase-progress {
    max-width: 640px;
    height: 10px;
}

.header-text {
    margin: 0 0 26px;
    padding: 20px 22px;
    border: 1px solid var(--border);
    border-left: 5px solid var(--accent);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
    line-height: 1.65;
    white-space: pre-wrap;
}

.save-message {
    min-height: 24px;
    margin: 0 0 8px;
    color: var(--success);
    font-size: 0.92rem;
    font-weight: 700;
}

.save-message.is-error {
    color: var(--danger);
}

.task-grid {
    display: grid;
    gap: 22px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
    align-items: start;
}

.task-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
    transition:
        border-color 180ms ease,
        box-shadow 180ms ease;
}

.task-card.is-done {
    border-color: rgba(22, 128, 58, 0.45);
    box-shadow: 0 12px 30px rgba(22, 128, 58, 0.12);
}

.image-frame {
    position: relative;
    display: grid;
    min-height: 220px;
    max-height: 72vh;
    place-items: center;
    overflow: hidden;
    background:
        linear-gradient(45deg, #edf0f3 25%, transparent 25%),
        linear-gradient(-45deg, #edf0f3 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #edf0f3 75%),
        linear-gradient(-45deg, transparent 75%, #edf0f3 75%),
        #f8fafb;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
}

.image-frame img {
    display: block;
    width: 100%;
    max-height: 72vh;
    object-fit: contain;
}

.check-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    opacity: 0;
    background: var(--success-soft);
    pointer-events: none;
    transition: opacity 180ms ease;
}

.check-overlay svg {
    width: clamp(110px, 30%, 210px);
    overflow: visible;
    fill: rgba(255, 255, 255, 0.84);
    filter: drop-shadow(0 8px 18px rgba(0, 70, 25, 0.22));
    stroke: rgba(14, 145, 55, 0.78);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 10;
}

.check-overlay circle {
    stroke-width: 7;
}

.task-card.is-done .check-overlay {
    opacity: 1;
}

.task-details {
    padding: 18px;
}

.task-filename {
    margin-bottom: 12px;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 0.83rem;
    line-height: 1.4;
}

.task-description {
    margin-bottom: 16px;
    padding: 13px 14px;
    border-radius: 10px;
    background: var(--surface-soft);
    line-height: 1.6;
    white-space: pre-wrap;
}

.task-toggle {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--accent);
    border-radius: 11px;
    color: #ffffff;
    background: var(--accent);
    font-weight: 800;
    cursor: pointer;
    transition:
        background 150ms ease,
        border-color 150ms ease,
        transform 100ms ease;
}

.task-toggle:hover:not(:disabled) {
    border-color: var(--accent-dark);
    background: var(--accent-dark);
}

.task-toggle:active:not(:disabled) {
    transform: translateY(1px);
}

.task-toggle:disabled {
    cursor: wait;
    opacity: 0.68;
}

.task-card.is-done .task-toggle {
    border-color: #91a09a;
    color: #26312c;
    background: #e7ece9;
}

.task-card.is-done .task-toggle:hover:not(:disabled) {
    border-color: #687870;
    background: #dce3df;
}

.empty-state {
    padding: 38px 24px;
    border: 1px dashed #aeb8c2;
    border-radius: 16px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.7);
    text-align: center;
}

.empty-state h2 {
    color: var(--text);
}

.empty-state p {
    margin-bottom: 0;
}

@media (max-width: 640px) {
    .site-shell {
        width: min(100% - 22px, 1180px);
        padding-top: 28px;
    }

    .phase-card {
        min-height: 130px;
        padding: 19px;
    }

    .phase-number {
        width: 45px;
        height: 45px;
    }

    .task-grid {
        gap: 16px;
    }

    .task-details {
        padding: 15px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

/* Phase display setting */
.display-settings {
    display: flex;
    margin-top: 20px;
}

.setting-toggle {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    min-height: 44px;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: 0 5px 16px rgba(20, 32, 48, 0.06);
    font-size: 0.92rem;
    font-weight: 750;
    cursor: pointer;
    user-select: none;
}

.setting-toggle input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
}

.hide-filenames .task-filename {
    display: none;
}

.hide-filenames .task-description:first-child {
    margin-top: 0;
}

/* Clickable task images */
.image-open-button {
    position: relative;
    display: grid;
    width: 100%;
    min-height: inherit;
    max-height: inherit;
    margin: 0;
    padding: 0;
    place-items: center;
    overflow: hidden;
    border: 0;
    color: inherit;
    background: transparent;
    cursor: zoom-in;
}

.image-open-button:focus-visible {
    outline: 4px solid rgba(33, 86, 216, 0.52);
    outline-offset: -4px;
}

.image-open-button img {
    display: block;
    width: 100%;
    max-height: 72vh;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.image-open-button .check-overlay {
    pointer-events: none;
}

/* Full-screen image viewer */
body.viewer-open {
    overflow: hidden;
    overscroll-behavior: none;
}

.image-viewer {
    position: fixed;
    z-index: 10000;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    color: #ffffff;
    background: #000000;
    -webkit-tap-highlight-color: transparent;
}

@supports (height: 100dvh) {
    .image-viewer {
        height: 100dvh;
        min-height: 100dvh;
    }
}

.image-viewer[hidden] {
    display: none !important;
}

.viewer-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: zoom-out;
    touch-action: none;
    user-select: none;
    overscroll-behavior: none;
}

.viewer-stage.is-zoomed {
    cursor: grab;
}

.viewer-stage.is-zoomed:active {
    cursor: grabbing;
}

.viewer-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform: translate3d(0, 0, 0) scale(1);
    transform-origin: center center;
    will-change: transform;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

@supports (height: 100dvh) {
    .viewer-image {
        max-height: 100dvh;
    }
}

.viewer-close {
    position: absolute;
    z-index: 2;
    top: max(14px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    display: grid;
    width: 52px;
    height: 52px;
    padding: 0 0 5px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.56);
    border-radius: 999px;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.7);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

.viewer-close:hover {
    background: rgba(45, 45, 45, 0.95);
}

.viewer-close:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.86);
    outline-offset: 3px;
}

.viewer-help {
    position: absolute;
    z-index: 2;
    right: 16px;
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 16px;
    width: fit-content;
    max-width: calc(100% - 32px);
    margin: 0 auto;
    padding: 8px 13px;
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.86);
    background: rgba(0, 0, 0, 0.62);
    font-size: 0.78rem;
    text-align: center;
    pointer-events: none;
}

@media (hover: none) {
    .viewer-help {
        font-size: 0.72rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .viewer-image {
        will-change: auto;
    }
}
