:root {
    color-scheme: light;
    --bg: #f1f1ef;
    --card: #ffffff;
    --ink: #111111;
    --muted: #696966;
    --line: #d7d7d2;
    --line-strong: #aaa9a4;
    --soft: #ececea;
    --soft-dark: #d9d9d5;
    --black: #111111;
    --white: #ffffff;
    --red: #b50918;
    --red-soft: #fff0f1;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(rgb(17 17 17 / 2%) 1px, transparent 1px),
        linear-gradient(90deg, rgb(17 17 17 / 2%) 1px, transparent 1px),
        var(--bg);
    background-size: 32px 32px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
    line-height: 1.65;
}

button, input, select { font: inherit; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
    outline: 3px solid #777;
    outline-offset: 3px;
}

.wrap {
    width: min(1200px, calc(100% - 40px));
    margin: 0 auto;
    padding: 44px 0 80px;
}

.head,
.section-title,
.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.header-copy { max-width: 720px; }

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.brand-mark {
    display: inline-grid;
    width: 28px;
    height: 28px;
    place-items: center;
    color: var(--white);
    background: var(--black);
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
}

h1, h2 { margin-top: 0; letter-spacing: -.035em; }
h1 {
    max-width: 720px;
    margin-bottom: 9px;
    font-size: clamp(32px, 4vw, 48px);
    font-weight: 850;
    line-height: 1.15;
}
h2 { margin-bottom: 12px; font-size: 22px; line-height: 1.35; }

.lead {
    max-width: 680px;
    margin: 0 0 10px;
    color: #474744;
    font-size: 16px;
}

.period { margin: 0; font-size: 13px; }

.eyebrow,
.section-kicker {
    margin: 0;
    color: var(--ink);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: .18em;
    line-height: 1.3;
}

.section-kicker { margin-bottom: 6px; }
.muted { color: var(--muted); }

.actions, .tools, .upload-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.actions { justify-content: flex-end; }

.btn {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--black);
    border-radius: 4px;
    color: var(--white);
    background: var(--black);
    box-shadow: 3px 3px 0 #b9b9b5;
    cursor: pointer;
    font-weight: 750;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease, color .15s ease, background .15s ease;
}

.btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 5px 5px 0 #b9b9b5;
}

.btn.secondary {
    color: var(--ink);
    background: var(--white);
    box-shadow: none;
}

.btn.secondary:hover { color: var(--white); background: var(--black); }

.btn.danger {
    border-style: double;
    border-width: 3px;
    box-shadow: none;
}

.btn:disabled { cursor: wait; opacity: .7; transform: none; }
.btn.disabled {
    cursor: not-allowed;
    opacity: .48;
    box-shadow: none;
    pointer-events: none;
}

.notice {
    margin: 20px 0;
    padding: 13px 15px;
    border: 1px solid var(--ink);
    border-radius: 4px;
    color: var(--ink);
    background: var(--white);
    font-size: 14px;
}

.notice.error {
    border-left: 7px solid var(--ink);
    font-weight: 700;
}

.expiry {
    margin: 0;
    white-space: nowrap;
}

.sync-panel {
    position: relative;
    display: grid;
    grid-template-columns: minmax(260px, .9fr) minmax(360px, 1.1fr);
    gap: 24px 44px;
    margin-top: 34px;
    padding: 30px;
    overflow: hidden;
    border: 1px solid var(--black);
    border-radius: 6px;
    background: rgb(255 255 255 / 96%);
    box-shadow: 8px 8px 0 #c9c9c5;
}

.sync-panel::after {
    position: absolute;
    right: -35px;
    bottom: -74px;
    width: 180px;
    height: 180px;
    border: 24px solid #e4e4e1;
    content: "";
    opacity: .7;
    pointer-events: none;
    transform: rotate(22deg);
}

.sync-intro { position: relative; z-index: 1; }
.sync-intro h2 { margin-top: 10px; font-size: 25px; }

.privacy-note {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 8px;
    margin: 18px 0 0;
    color: #333331;
    font-size: 13px;
}

.privacy-note::before {
    width: 12px;
    height: 12px;
    margin-top: 5px;
    border: 2px solid var(--ink);
    content: "";
}

.privacy-note strong { display: block; }

.login-form {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-content: start;
}

label span {
    display: block;
    margin-bottom: 6px;
    color: #40403d;
    font-size: 13px;
    font-weight: 750;
}

input, select {
    min-height: 44px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 3px;
    color: var(--ink);
    background: #fff;
    outline: none;
}

input::placeholder { color: #92928e; }

input:focus, select:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 2px var(--ink);
}

.sync-button { grid-column: 1 / -1; min-height: 48px; }

.advanced-options {
    grid-column: 1 / -1;
    padding: 10px 12px;
    border: 1px dashed var(--line-strong);
    border-radius: 3px;
    background: #f7f7f5;
}
.advanced-options summary {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.advanced-options[open] summary { margin-bottom: 12px; }
.advanced-options p { margin: 7px 0 0; font-size: 12px; }

.sync-meta {
    z-index: 1;
    display: flex;
    grid-column: 1 / -1;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
    padding-top: 15px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}

.status-row { display: inline-flex; align-items: center; gap: 8px; }
.status-dot {
    width: 8px;
    height: 8px;
    border: 1px solid var(--ink);
    background: var(--ink);
}

.spinner {
    display: none;
    width: 17px;
    height: 17px;
    border: 2px solid rgb(255 255 255 / 45%);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.is-loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.section-heading {
    align-items: flex-end;
    margin: 34px 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--black);
}
.section-heading h2 { margin: 0; font-size: 26px; }
.section-heading p:last-child { margin: 0; font-size: 13px; }

.cards {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin: 0 0 24px;
}

.card, .upload, .how-it-works {
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--card);
    box-shadow: 3px 3px 0 #dededb;
}

.card {
    min-width: 0;
    padding: 21px;
}
.metric {
    position: relative;
    min-height: 126px;
    overflow: hidden;
}
.metric::after {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 18px;
    height: 18px;
    border-right: 2px solid var(--line-strong);
    border-bottom: 2px solid var(--line-strong);
    content: "";
}
.big {
    margin-top: 4px;
    font-size: 38px;
    font-weight: 880;
    letter-spacing: -.055em;
    line-height: 1.15;
}
.section {
    min-width: 0;
    margin-top: 26px;
}

.table-scroll {
    width: 100%;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 3px;
}

.timeline { max-height: 800px; background: #fff; }

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th, td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    text-align: left;
}

th {
    position: sticky;
    z-index: 2;
    top: 0;
    color: #3e3e3b;
    background: #e8e8e5;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

tbody tr:hover { background: #f5f5f3; }
tr:last-child td { border-bottom: 0; }
.redrow {
    background: var(--red-soft);
    box-shadow: inset 4px 0 0 var(--red);
}
.redrow:hover { background: #ffe4e6; }
.content { max-width: 560px; white-space: pre-wrap; overflow-wrap: anywhere; }

.pill {
    display: inline-block;
    padding: 3px 8px;
    border: 1px solid #b7b7b2;
    border-radius: 999px;
    color: #444441;
    background: #f3f3f1;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
}

.pill.red {
    border-color: var(--red);
    color: var(--white);
    background: var(--red);
    font-weight: 800;
}
.pill.amber {
    border-color: #777773;
    color: var(--ink);
    background: #d5d5d1;
    font-weight: 700;
}

.red-summary {
    color: var(--red);
    font-size: 13px;
    font-weight: 800;
}

.chart-scroll { overflow-x: auto; padding: 6px 4px 0; }
.chart {
    display: flex;
    min-width: max-content;
    height: 170px;
    align-items: flex-end;
    gap: 9px;
    padding: 15px 0 0;
}

.bar-wrap {
    display: grid;
    width: 28px;
    justify-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 11px;
}
.bar {
    width: 24px;
    min-height: 4px;
    border: 1px solid var(--black);
    border-radius: 2px 2px 0 0;
    background: repeating-linear-gradient(135deg, #111 0, #111 4px, #555 4px, #555 7px);
}
.empty { margin-bottom: 0; }

.upload, .how-it-works { padding: 16px 18px; }
.delete-result {
    padding: 16px 18px;
    border: 2px solid var(--black);
    box-shadow: none;
}
.delete-result[open] summary { margin-bottom: 12px; color: var(--ink); }
.delete-result p { max-width: 760px; }
summary { cursor: pointer; font-weight: 750; }
.upload-form { margin-top: 16px; align-items: center; }
.upload-form input[type="file"] { width: auto; flex: 1 1 280px; }
.tools { justify-content: flex-end; }
.tools input { min-width: min(320px, 100%); }
.tools select { width: auto; }
.how-it-works ol { margin-bottom: 0; color: #484845; line-height: 1.8; }
code { padding: 2px 5px; border-radius: 2px; background: #e2e2df; }

.result-info {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.result-info::before {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin-top: 4px;
    border: 2px solid var(--ink);
    content: "";
}
.result-info p { margin: 0; }

.setup-card { max-width: 760px; }
.setup-form {
    display: grid;
    max-width: 560px;
    gap: 14px;
    margin-top: 20px;
}
.setup-actions { margin-top: 18px; }
.setup-status-cards { grid-template-columns: repeat(3, 1fr); }
.setup-status {
    margin-top: 6px;
    font-size: 30px;
    font-weight: 850;
    letter-spacing: -.04em;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 850px) {
    .wrap { width: min(100% - 28px, 1200px); }
    .sync-panel { grid-template-columns: 1fr; }
    .cards { grid-template-columns: 1fr 1fr; }
    .head, .section-title { display: block; }
    .actions, .tools { justify-content: flex-start; margin-top: 18px; }
    .expiry { display: inline-block; }
}

@media (max-width: 1100px) and (min-width: 851px) {
    .cards { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 560px) {
    .wrap { width: min(100% - 22px, 1200px); padding-top: 24px; }
    h1 { font-size: 32px; }
    .brand-lockup { margin-bottom: 13px; }
    .login-form { grid-template-columns: 1fr; }
    .sync-panel { margin-top: 26px; padding: 20px; box-shadow: 5px 5px 0 #c9c9c5; }
    .sync-button { grid-column: auto; }
    .section-heading { display: block; }
    .section-heading > p { margin-top: 7px !important; }
    .actions .btn, .tools > * { width: 100%; }
    .cards { gap: 9px; }
    .setup-status-cards { grid-template-columns: 1fr; }
    .card { padding: 15px; }
    .metric { min-height: 108px; }
    .big { font-size: 31px; }
    .metric::after { width: 12px; height: 12px; }
    .sync-meta { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
