:root {
    color-scheme: light dark;
    --accent: light-dark(#1e6fc0, #6fb1f5);
    --accent-text: light-dark(#ffffff, #0b1f33);
    --text: light-dark(#222831, #e8eaed);
    --muted: light-dark(#5f6672, #a3aab5);
    --surface: light-dark(#ffffff, #1c1f24);
    --page: light-dark(#f4f6fa, #121417);
    --line: light-dark(#d9dee6, #3a4049);
    --today: light-dark(#e3eefb, #1f3550);
    --sunday: light-dark(#d93025, #ff8a80);
    --saturday: light-dark(#1a73e8, #8ab4f8);
    --danger: light-dark(#b3261e, #ffb4ab);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 16px clamp(12px, 3vw, 32px) 32px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Yu Gothic UI', 'Hiragino Sans', Meiryo, sans-serif;
    line-height: 1.7;
    color: var(--text);
    background: var(--page);
}

a { color: var(--accent); }

.site-header { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; }
.breadcrumb { margin: 0; font-size: 0.85rem; color: var(--muted); }
h1 { margin: 4px 0 8px; font-size: 1.5rem; }
h2 { margin: 0 0 8px; font-size: 1.15rem; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; background: var(--accent); color: var(--accent-text); vertical-align: middle; }
.account { display: flex; gap: 8px; }

button, select, input[type="text"], input[type="time"] {
    font: inherit;
    color: inherit;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}
button { cursor: pointer; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* 広告。操作するボタンから離して上に置き、読み込みで下の内容が動かないよう高さを先に取る */
.ad { margin: 8px 0 4px; text-align: center; min-block-size: calc(160px + 1.4rem); }
@media (width >= 800px) {
    .ad { min-block-size: calc(90px + 1.4rem); }
}
.ad-label { margin: 0 0 2px; font-size: 0.72rem; letter-spacing: 0.04em; color: var(--muted); }
.ad iframe { max-inline-size: 100%; }

#status { min-height: 1.7em; margin: 4px 0; color: var(--muted); }
#status.error { color: var(--danger); font-weight: 600; }

#welcome, .records, .export {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: clamp(14px, 2vw, 24px);
}
#welcome { max-width: 760px; }
.notes { padding-left: 1.2em; color: var(--muted); font-size: 0.92rem; }

#workspace { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
#workspace[hidden] { display: none; }
@media (width >= 1200px) {
    #workspace { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
    .export { position: sticky; top: 12px; }
}

.month-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.month-bar button { width: 52px; height: 52px; padding: 0; border-radius: 50%; font-size: 1.6rem; line-height: 1; color: var(--accent); }
.month-title { text-align: center; }
.month-title h2 { margin: 0; font-size: 1.3rem; }
.month-title p { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 8px 0; }

.table-wrapper { overflow: auto; max-inline-size: 100%; max-block-size: min(70vh, 900px); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: separate; border-spacing: 0; inline-size: 100%; font-variant-numeric: tabular-nums; }
thead { position: sticky; inset-block-start: 0; z-index: 1; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; font-size: 0.93rem; }
thead th { background: var(--page); font-size: 0.85rem; color: var(--muted); }
tbody th { font-weight: 600; }
td.number { text-align: right; }
td.status { text-align: center; }
td.summary { white-space: normal; min-width: 9em; inline-size: 100%; }
tr.sunday th { color: var(--sunday); }
tr.saturday th { color: var(--saturday); }
tr.today th, tr.today td { background: var(--today); }
tr.off td { color: var(--muted); }
td button { padding: 2px 12px; font-size: 0.85rem; }

fieldset { border: 0; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
legend { padding: 0; margin-bottom: 4px; font-size: 0.85rem; color: var(--muted); }
.field { display: grid; gap: 2px; margin-bottom: 12px; }
.field > label { font-size: 0.85rem; color: var(--muted); }
.field.inline { display: flex; gap: 8px; align-items: center; }
.field.inline > label { font-size: 1rem; color: var(--text); }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }

#preview { inline-size: 100%; block-size: min(78vh, 1000px); border: 1px solid var(--line); border-radius: 12px; background: #fff; }

dialog { border: 1px solid var(--line); border-radius: 16px; padding: 20px; inline-size: min(520px, 92vw); color: var(--text); background: var(--surface); }
dialog h1 { font-size: 1.2rem; margin: 0 0 12px; }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: rgb(0 0 0 / 0.4); overflow: hidden; overscroll-behavior: contain; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
dialog input[type="text"] { inline-size: 100%; }

footer { margin-top: 24px; color: var(--muted); font-size: 0.85rem; }

.visually-hidden { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
