/* 誕生日フォルダ */
/* レイアウト: 最初はフォルダの一覧。フォルダを開くと、その中の「次の誕生日」と一覧が見える（1カラム） */
:root {
    --bg: #f2f3f7;
    --surface: #ffffff;
    --surface-2: #e8eaf1;
    --ink: #1b1f2e;
    --muted: #3c4152;
    --line: #d8dbe5;
    --accent: #c9334f;
    --accent-ink: #ffffff;
    --accent-soft: #fbe4e9;
    --today: #fff0d1;
    --today-ink: #7d4a00;
    --danger: #b3261e;
    --c-amber: #e09a12;
    --c-amber-l: #f8c84d;
    --c-rose: #d6416b;
    --c-rose-l: #f28ba8;
    --c-blue: #3463c9;
    --c-blue-l: #82a3ee;
    --c-green: #2f8f4e;
    --c-green-l: #72c78d;
    --c-teal: #13878f;
    --c-teal-l: #62c5cb;
    --c-orange: #d9662a;
    --c-orange-l: #f59c66;
    --c-violet: #7a4cc4;
    --c-violet-l: #b090e8;
    --c-gray: #6b7083;
    --c-gray-l: #a9adbb;
    --font-display: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", "Yu Gothic", "Meiryo", sans-serif;
    --font-body: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", "Yu Gothic", "Meiryo", sans-serif;
    --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(27, 31, 46, 0.06), 0 6px 18px rgba(27, 31, 46, 0.06);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 19px;
    line-height: 1.6;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-block: 20px 48px;
}

.app {
    max-width: 640px;
    margin: 0 auto;
}

[data-color="amber"] { --fc: var(--c-amber); --fc-l: var(--c-amber-l); }
[data-color="rose"] { --fc: var(--c-rose); --fc-l: var(--c-rose-l); }
[data-color="blue"] { --fc: var(--c-blue); --fc-l: var(--c-blue-l); }
[data-color="green"] { --fc: var(--c-green); --fc-l: var(--c-green-l); }
[data-color="teal"] { --fc: var(--c-teal); --fc-l: var(--c-teal-l); }
[data-color="orange"] { --fc: var(--c-orange); --fc-l: var(--c-orange-l); }
[data-color="violet"] { --fc: var(--c-violet); --fc-l: var(--c-violet-l); }
[data-color="gray"] { --fc: var(--c-gray); --fc-l: var(--c-gray-l); }

/* 画面切り替え（display: none） */
.screen {
    display: none;
}

.screen.is-active {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 700;
    margin: 0;
    text-wrap: balance;
    line-height: 1.3;
}

h1 {
    font-size: 27px;
}

h2 {
    font-size: 25px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.brand small {
    color: var(--muted);
    font-size: 16px;
    letter-spacing: 0.04em;
}

.folder-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.folder-heading h2 {
    overflow-wrap: anywhere;
}

/* フォルダアイコン（📁を模したSVG） */
.ficon {
    flex: none;
    display: block;
}

.ficon .fi-back {
    fill: var(--fc, var(--c-amber));
}

.ficon .fi-front {
    fill: var(--fc-l, var(--c-amber-l));
}

/* ボタン（操作用） */
.btn {
    appearance: none;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 500;
    font-size: 18px;
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    line-height: 1.3;
    white-space: nowrap;
}

.btn:hover {
    background: var(--surface-2);
}

.btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.btn-primary:hover {
    background: var(--accent);
    filter: brightness(1.06);
}

.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
    background: transparent;
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--muted);
}

.btn-wide {
    width: 100%;
    padding: 12px 16px;
    font-size: 19px;
}

.btn:focus-visible,
.row-btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ラジオ・チェックボックスをボタン風に見せる（labelで囲み、labelを装飾） */
.chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.chip input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.chip:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.chip[data-color]:has(input:checked) {
    background: var(--surface);
    border-color: var(--fc);
    box-shadow: inset 0 0 0 1px var(--fc);
}

.chip:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.chip .count {
    font-size: 16px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.chip-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 999px;
    background: var(--surface-2);
    gap: 2px;
}

.segmented .chip {
    border-color: transparent;
    background: transparent;
    padding: 5px 14px;
    font-size: 17px;
}

.segmented .chip:has(input:checked) {
    background: var(--surface);
    border-color: var(--line);
    box-shadow: none;
}

/* スイッチ型チェックボックス */
.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 18px;
    user-select: none;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.switch .track {
    width: 40px;
    height: 24px;
    border-radius: 999px;
    background: var(--line);
    position: relative;
    flex: none;
    transition: background 0.15s;
}

.switch .track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s;
}

.switch:has(input:checked) .track {
    background: var(--accent);
}

.switch:has(input:checked) .track::after {
    transform: translateX(16px);
}

.switch:has(input:focus-visible) .track {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* 色選び（フォルダの形） */
.swatches {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.swatch {
    position: relative;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    cursor: pointer;
}

.swatch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.swatch:has(input:checked) {
    border-color: var(--fc);
    box-shadow: inset 0 0 0 1px var(--fc);
    background: var(--bg);
}

.swatch:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* フォルダ一覧 */
.panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.row-btn {
    appearance: none;
    width: 100%;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 14px 18px;
    border-top: 1px solid var(--line);
}

.row-btn:first-child,
.group-head + .row-btn {
    border-top: none;
}

.row-btn:hover {
    background: var(--surface-2);
}

.folder-item {
    display: flex;
    align-items: center;
    border-top: 1px solid var(--line);
}

.folder-item:first-child {
    border-top: none;
}

.folder-item .row-btn {
    border-top: none;
    flex: 1;
    min-width: 0;
    grid-template-columns: 40px 1fr;
    padding-block: 16px;
}

.folder-item .who-name {
    font-size: 21px;
}

.chevron {
    color: var(--muted);
    font-size: 22px;
}

.order-btns {
    display: flex;
    gap: 2px;
    padding-right: 10px;
}

.order-btns .btn {
    padding: 6px 10px;
}

.folder-meta-today {
    color: var(--today-ink);
    font-weight: 700;
}

/* 次の誕生日 */
.next {
    background: var(--accent-soft);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 16px;
    align-items: center;
}

.next.is-today {
    background: var(--today);
}

.next-label {
    grid-column: 1 / -1;
    font-size: 16px;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 700;
}

.next-name {
    font-family: var(--font-display);
    font-size: 27px;
    font-weight: 700;
    line-height: 1.3;
    min-width: 0;
    overflow-wrap: anywhere;
}

.next-person {
    display: block;
}

.next-sub {
    color: var(--muted);
    font-size: 17px;
}

.next-days {
    text-align: right;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
}

.next-days strong {
    font-family: var(--font-display);
    font-size: 44px;
    color: var(--accent);
}

.next.is-today .next-days strong {
    color: var(--today-ink);
    font-size: 28px;
}

.next-days span {
    font-size: 18px;
    margin-left: 2px;
}

/* 人の一覧 */
.list-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.total {
    color: var(--muted);
    font-size: 17px;
    font-variant-numeric: tabular-nums;
}

.group-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 12px 18px 6px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 19px;
    background: var(--surface-2);
    border-top: 1px solid var(--line);
}

.group-head:first-child {
    border-top: none;
}

.group-head span {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 16px;
    color: var(--muted);
}

.row-btn.is-today {
    background: var(--today);
}

.row-btn.person-row {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
        "date name days"
        "meta meta meta"
        "memo memo memo";
    column-gap: 12px;
    row-gap: 2px;
}

.person-row .date-block {
    grid-area: date;
    text-align: left;
}

.person-row .who-name {
    grid-area: name;
    min-width: 0;
}

.person-row .who-meta {
    grid-area: meta;
    min-width: 0;
}

.person-row .who-memo {
    grid-area: memo;
    min-width: 0;
}

.person-row .days {
    grid-area: days;
    align-self: center;
}

.date-block {
    display: block;
    text-align: center;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.date-block b {
    display: block;
    font-family: var(--font-display);
    font-size: 22px;
}

.date-block small {
    font-size: 14px;
    color: var(--muted);
}

.who {
    display: block;
    min-width: 0;
}

.who-name {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-weight: 700;
    font-size: 20px;
    overflow-wrap: anywhere;
}

.badge {
    font-size: 14px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    letter-spacing: 0.02em;
}

.who-meta {
    display: block;
    color: var(--muted);
    font-size: 17px;
    font-variant-numeric: tabular-nums;
}

.emoji {
    font-family: var(--font-emoji);
    font-size: 23px;
    line-height: 1;
    vertical-align: -3px;
}

.who-memo {
    display: block;
    color: var(--muted);
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.days {
    display: block;
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    line-height: 1.2;
}

.days b {
    font-family: var(--font-display);
    font-size: 25px;
}

.days.is-today b {
    color: var(--today-ink);
    font-size: 19px;
}

.days.is-soon b {
    color: var(--accent);
}

.empty {
    padding: 36px 20px;
    text-align: center;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.empty p {
    margin: 0;
}

.privacy {
    color: var(--muted);
    font-size: 16px;
    text-align: center;
    margin: 0;
}

/* フォーム */
.form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.field-label {
    font-size: 17px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.04em;
}

.field input[type="text"],
.field select,
.field textarea,
.share-out {
    width: 100%;
    font: inherit;
    font-size: 20px;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
}

.field textarea {
    min-height: 72px;
    resize: vertical;
}

.field select:disabled {
    opacity: 0.45;
}

.date-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 8px;
}

.error {
    color: var(--danger);
    font-size: 17px;
    margin: 0;
}

.error:empty {
    display: none;
}

.preview {
    font-size: 17px;
    color: var(--muted);
    background: var(--surface-2);
    border-radius: 10px;
    padding: 10px 12px;
    font-variant-numeric: tabular-nums;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: space-between;
}

.form-actions .right {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

.back {
    align-self: flex-start;
}

.hint {
    color: var(--muted);
    font-size: 17px;
    margin: 0;
}

.share-out {
    min-height: 96px;
    font-size: 17px;
    word-break: break-all;
    resize: vertical;
}

.import-list {
    margin: 0;
    padding-left: 1.2em;
    color: var(--muted);
    font-size: 18px;
}

/* 確認ダイアログ */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 20, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    z-index: 50;
}

.dialog {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    color: var(--ink);
    border-radius: 18px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--shadow);
}

.dialog p {
    margin: 0;
    color: var(--muted);
    font-size: 18px;
}

.dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.dialog-actions .btn-ghost {
    margin-right: auto;
}

.transfer-step {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.transfer-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dialog {
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}


.toast {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--bg);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 18px;
    z-index: 60;
    max-width: calc(100% - 32px);
    text-align: center;
}

@media (max-width: 420px) {
    .row-btn {
        grid-template-columns: 52px 1fr auto;
        gap: 8px;
        padding: 12px 12px;
    }

    .row-btn.person-row {
        grid-template-columns: auto 1fr auto;
        column-gap: 10px;
    }

    .next-days strong {
        font-size: 36px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
