/* 書体: 本文=Zen Kaku Gothic New ／ 数字=Inter（等幅数字） ／ 店名=Zen Old Mincho。読み込みは各HTMLの<link>で行う */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-primary: #0c0b0e;
    --bg-secondary: #141318;
    --bg-card: #1b1a21;
    --bg-card-hover: #24222c;
    --bg-glass: rgba(255, 255, 255, 0.045);
    --border-glass: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text-primary: #f4f1ea;
    --text-secondary: #c2bfc9;
    --text-muted: #8f8c99;
    /* 色の使い分け: --accent は看板の赤＝「操作に必要なボタン・リンク」だけに使う。
       --warn（黄）は注意書き、--danger（赤）は要修正・エラー。それ以外は無彩色 */
    --accent: #d9441c;
    --accent-strong: #b8300f;
    --accent-glow: rgba(217, 68, 28, 0.28);
    --accent-dim: #8a8578;
    --tag-bg: rgba(255, 255, 255, 0.07);
    --price-color: #f4f1ea;
    --off-menu: #ff7b7b;
    --danger: #ff7b7b;
    --ok: #5fd38a;
    --warn: #f2c14e;
    --warn-bg: rgba(242, 193, 78, 0.10);
    --warn-border: rgba(242, 193, 78, 0.45);
    --info: #c2bfc9;
    --note-bg: rgba(242, 193, 78, 0.08);
    --note-border: rgba(242, 193, 78, 0.35);
    --paper: #fbfaf6;
    --paper-2: #ebe7dd;
    --paper-3: #e3dfd4;
    --paper-line: #d3cec1;
    --paper-text: #17161a;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius: 14px;
    --radius-sm: 10px;
    --font-body: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
    --font-num: 'Inter', 'Zen Kaku Gothic New', sans-serif;
    --font-brand: 'Zen Old Mincho', 'Hiragino Mincho ProN', serif;
    --hdr-h: 0px;
    --bar-h: 0px;
}

html {
    font-size: 16px;
}

/* 方針: ヘッダーもバーも浮かせない（position: fixed を使わない）。
   通常の流れに置き、sticky で画面の上端・下端に貼り付ける。古い iOS でも余白が生まれない */
body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
}

[hidden] {
    display: none !important;
}

/* 画面の切り替え: html[data-view] と一致しない data-view 要素を隠す（nav.js が data-view を更新する） */
html[data-view="recipes"] [data-view]:not([data-view="recipes"]),
html[data-view="manual"] [data-view]:not([data-view="manual"]),
html[data-view="slip"] [data-view]:not([data-view="slip"]),
html:not([data-view]) [data-view]:not([data-view="recipes"]) {
    display: none !important;
}

/* 金額や件数は等幅数字で桁をそろえる */
.num,
.drink-price,
.header-title .count {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
}

/* Header */
.header {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-glass);
    padding: 10px 16px 0;
}

.header-recipes {
    padding-top: 10px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.header-title h1 {
    font-family: var(--font-brand);
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    line-height: 1.3;
    color: var(--text-primary);
}

.brand {
    display: inline-block;
    line-height: 0;
}

.brand-logo {
    display: block;
    height: 42px;
    width: auto;
}

.header-title .count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Search Box */
.search-container {
    position: relative;
    margin-bottom: 12px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.2s;
}

.search-input {
    width: 100%;
    padding: 12px 44px 12px 42px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.25s ease;
}

.search-input::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

.search-input:focus {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.search-input:focus~.search-icon {
    color: var(--text-secondary);
}

.search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 0.85rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.search-clear.visible {
    display: flex;
}

.search-clear:active {
    background: rgba(255, 255, 255, 0.15);
}

/* Category Tabs */
.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding-bottom: 12px;
}

.tab {
    padding: 7px 0;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex: 1 1 calc(16.666% - 5px);
    min-width: calc(16.666% - 5px);
    max-width: calc(20% - 5px);
    text-align: center;
}

.tab:active {
    transform: scale(0.95);
}

.tab.active {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
    font-weight: 700;
}

/* Drink List */
.drink-list {
    padding: 8px 16px 24px;
}

.drink-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.drink-card:active {
    transform: scale(0.99);
}

.drink-card.expanded {
    border-color: var(--border-strong);
}

.drink-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    gap: 10px;
    user-select: none;
}

.drink-name {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
}

.drink-name mark {
    background: rgba(255, 255, 255, 0.18);
    color: var(--text-primary);
    border-radius: 2px;
    padding: 0 1px;
}

.off-menu-badge {
    font-size: 0.6rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 1px 5px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0.8;
}

.drink-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--price-color);
    white-space: nowrap;
}

.drink-chevron {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.drink-card.expanded .drink-chevron {
    transform: rotate(90deg);
}

/* Recipe Detail */
.drink-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.drink-card.expanded .drink-detail {
    max-height: 600px;
}

.drink-detail-inner {
    padding: 0 16px 16px;
}

.detail-section {
    margin-bottom: 10px;
}

.detail-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 4px;
    font-weight: 500;
}

.detail-glass {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--tag-bg);
    padding: 4px 10px;
    border-radius: 6px;
}

.detail-price-note {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.recipe-text {
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.7;
    font-weight: 300;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    padding: 12px;
    border-left: 3px solid var(--border-strong);
    white-space: pre-line;
}

.note-text {
    font-size: 0.8rem;
    color: var(--warn);
    background: var(--note-bg);
    border: 1px solid var(--note-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    line-height: 1.5;
    font-weight: 400;
}

.note-text::before {
    content: '💡 ';
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.9rem;
    font-weight: 300;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.drink-card {
    animation: fadeIn 0.25s ease both;
}

/* Navigation */
.nav-tabs {
    position: relative;
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-glass);
    margin: 0 -16px;
    padding: 0 8px;
}

/* 選択中のタブの下線。nav.js が位置と幅を決め、切り替え時に横へ滑る */
.nav-ink {
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 0;
    height: 2px;
    border-radius: 2px;
    background: var(--text-primary);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), width 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform;
}

.nav-tab {
    flex: 1;
    position: relative;
    text-align: center;
    padding: 11px 0 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    transition: color 0.2s;
}

.nav-tab.active {
    color: var(--text-primary);
    font-weight: 700;
}

/* Viewport Optimizations */
@supports (padding: env(safe-area-inset-bottom)) {
    .header {
        padding-top: calc(12px + env(safe-area-inset-top));
    }
}
/* Slip: warnings & PIN */
.slip-warning {
    margin-bottom: 12px;
    padding: 8px 12px 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.78rem;
    line-height: 1.5;
}

.slip-warning-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 2px 10px;
    margin-bottom: 4px;
}

.slip-warning-title {
    font-weight: 700;
}

.slip-warning-key {
    display: flex;
    gap: 10px;
    font-size: 0.68rem;
    color: var(--text-secondary);
}

.slip-warning-key span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.slip-warning ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.slip-warning li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 3px 0;
}

.w-dot {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-top: 0.45em;
    box-sizing: border-box;
}

.slip-warning-key .w-dot {
    margin-top: 0;
}

.w-fix .w-dot { background: var(--danger); }
.w-check .w-dot { background: var(--warn); }
.w-info .w-dot { border: 1.5px solid var(--text-muted); }
.slip-warning li.w-info { color: var(--text-secondary); }


/* Login */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 20px 24px;
    max-width: 380px;
    margin: 0 auto;
    text-align: center;
}

.login-mark {
    display: none;
}

.login-logo-img {
    display: block;
    width: 200px;
    height: auto;
    margin: 0 auto;
}

.login-title {
    margin: 0 0 14px;
    line-height: 0;
}

.login-lead {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.6;
    margin-bottom: 20px;
}

.login-form {
    width: 100%;
}

.login-input {
    display: block;
    width: 100%;
    padding: 14px;
    font-family: var(--font-num);
    font-size: 1.2rem;
    letter-spacing: 0.3em;
    text-align: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: rgba(255, 255, 255, 0.05);
    color: inherit;
    margin-bottom: 12px;
}

.login-input:focus {
    outline: none;
    border-color: var(--text-secondary);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.login-btn {
    width: 100%;
    min-height: 48px;
}

.login-error {
    margin-top: 12px;
    color: var(--off-menu);
    font-size: 0.88rem;
}

/* 今日の注意 */
.today-box {
    margin: 12px 16px;
    padding: 12px 14px;
    background: var(--note-bg);
    border: 1px solid var(--note-border);
    border-radius: var(--radius);
}

.today-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.today-title {
    font-weight: 700;
    color: var(--warn);
    font-size: 0.95rem;
}

.today-day {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.today-more {
    margin-left: auto;
    color: var(--accent);
    font-weight: 700;
    font-size: 0.78rem;
    text-decoration: none;
}

.today-list {
    list-style: none;
}

.today-item {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.92rem;
    line-height: 1.55;
    border-top: 1px solid var(--border-glass);
}

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

.today-icon {
    flex: none;
}

.today-todo {
    color: var(--text-primary);
    font-weight: 500;
}

.today-ok {
    color: var(--text-secondary);
}

.today-star {
    color: var(--warn);
    font-weight: 700;
}

.today-warn {
    color: var(--off-menu);
}

.today-box.compact {
    margin: 8px 16px 0;
    padding: 8px 12px;
}

.today-box.compact .today-item {
    font-size: 0.78rem;
    padding: 3px 0;
    line-height: 1.45;
}

.today-box.compact .today-title {
    font-size: 0.82rem;
}

/* マニュアル */
/* マニュアルの項目: 横スクロールにせず、2段（3列）で全部を最初から見せる */
.sec-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 10px 0 12px;
}

.sec-tab {
    padding: 9px 4px;
    border-radius: 8px;
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.sec-tab.active {
    color: var(--bg-primary);
    background: var(--text-primary);
    border-color: var(--text-primary);
    font-weight: 700;
}

.manual-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 4px 0 24px;
}

.manual-container .today-box {
    margin: 12px 16px;
}

.sec-panel>.m-acc,
.sec-panel>.m-card,
.sec-panel>.m-h,
.sec-panel>.m-p,
.sec-panel>.m-list,
.sec-panel>.m-intro,
.sec-panel>.chk-bar,
.sec-panel>.chk-list,
.sec-panel>.sup-search,
.sec-panel>.sup-list {
    margin-left: 16px;
    margin-right: 16px;
}

.m-h {
    margin-top: 22px;
    margin-bottom: 8px;
    font-size: 1rem;
    color: var(--text-primary);
}

.m-p {
    font-size: 0.9rem;
    line-height: 1.75;
    margin: 6px 0;
}

.m-list {
    margin: 6px 0 6px 1.3em;
    font-size: 0.9rem;
    line-height: 1.7;
}

.m-intro {
    margin-top: 12px;
    color: var(--text-secondary);
}

.m-acc {
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
}

.m-acc>summary {
    cursor: pointer;
    padding: 14px;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.5;
    list-style: none;
}

.m-acc>summary::-webkit-details-marker {
    display: none;
}

.m-acc>summary::before {
    content: '▶';
    display: inline-block;
    font-size: 0.65rem;
    margin-right: 8px;
    color: var(--text-muted);
    transition: transform 0.15s;
}

.m-acc[open]>summary::before {
    transform: rotate(90deg);
}

.m-acc-body {
    padding: 0 14px 12px;
}

.m-acc .m-acc {
    background: var(--bg-glass);
}

.m-card {
    margin-top: 10px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
}

.m-card-title {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* チェックリスト */
.chk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    margin-bottom: 8px;
}

.chk-counter {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 700;
}

.chk-reset {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.8rem;
}

.chk-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 12px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    min-height: 56px;
}

.chk-item input {
    flex: none;
    width: 26px;
    height: 26px;
    margin-top: 1px;
    accent-color: var(--accent);
}

.chk-body {
    flex: 1;
    min-width: 0;
}

.chk-title {
    display: block;
    font-size: 0.98rem;
    font-weight: 500;
    line-height: 1.5;
}

.chk-num {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.chk-detail {
    display: block;
    margin-top: 4px;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.chk-link {
    color: var(--accent);
    font-weight: 700;
    font-size: 0.9rem;
}

.chk-sub {
    margin: 6px 0 0 1.1em;
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.chk-sub ul {
    margin-left: 1.1em;
}

.chk-item.done {
    opacity: 0.55;
}

.chk-item.done .chk-title {
    text-decoration: line-through;
}

/* 備品 */
.sup-search {
    margin-top: 12px;
}

.sup-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: inherit;
}

.sup-item {
    margin-top: 8px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
}

.sup-item[hidden] {
    display: none;
}

.sup-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.sup-place {
    margin-top: 4px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.sup-empty {
    text-align: center;
    color: var(--text-muted);
}

.sec-panel[hidden] {
    display: none;
}

/* ===== 伝票計算 ===== */
.slip-container {
    padding: 16px;
    max-width: 980px;
    margin: 0 auto;
}

.slip-input-section {
    margin-bottom: 16px;
}

.slip-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.slip-textarea {
    width: 100%;
    min-height: 160px;
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.7;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.slip-textarea::placeholder {
    color: var(--text-muted);
}

.slip-textarea:focus {
    border-color: var(--text-secondary);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.slip-btn {
    padding: 12px 18px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, #e65a2c, var(--accent-strong));
    color: #fff;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
}

.slip-btn:active {
    transform: scale(0.97);
}

.slip-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.slip-btn-secondary {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    font-weight: 500;
}

.slip-btn.confirm {
    background: var(--danger);
    color: #1a0a0a;
}

.slip-btn-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.slip-btn-row .slip-btn {
    flex: 0 0 auto;
    padding: 10px 16px;
    font-size: 0.88rem;
}

.slip-hint {
    font-size: 0.75rem;
    color: var(--warn);
}

.slip-loading-inline {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.slip-error {
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(255, 123, 123, 0.1);
    border: 1px solid rgba(255, 123, 123, 0.35);
    border-radius: var(--radius-sm);
    color: var(--off-menu);
    font-size: 0.85rem;
}

.slip-banner {
    margin-bottom: 12px;
    padding: 10px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

.slip-banner.old {
    background: var(--warn-bg);
    border-color: var(--warn-border);
    color: var(--warn);
}

.slip-storage-warn {
    margin-bottom: 12px;
    padding: 10px 14px;
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    border-radius: var(--radius-sm);
    color: var(--warn);
    font-size: 0.85rem;
}

.slip-save-msg {
    min-height: 1.2em;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.slip-result-section {
    margin-top: 20px;
    scroll-margin-top: calc(var(--hdr-h) + 8px);
}

/* 金額の入力欄（買い物・クレカ・QR） */
.slip-amounts {
    margin: 16px 0;
    padding: 12px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.slip-amounts-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

.slip-edit-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.slip-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.74rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.slip-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 8px;
    font-size: 15px;
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    background: var(--paper);
    color: var(--paper-text);
    border: 1px solid var(--paper-line);
    border-radius: 6px;
    text-align: right;
    outline: none;
}

.slip-field input:focus {
    border-color: #5a5660;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

.slip-field .auto-note {
    font-size: 0.66rem;
    font-weight: 400;
    color: var(--text-muted);
    min-height: 1em;
}

/* 伝票の表: 紙の伝票風。横スクロールなし（幅320pxでも全列が見える固定レイアウト）。
   ページと一緒にスクロールし、見出し行はヘッダー直下に、合計行は画面の下端に固定される */
.slip-sheet-wrap {
    overflow: visible;
}

.slip-sheet {
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #8a8578;
    width: 100%;
    table-layout: fixed;
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    color: var(--paper-text);
}

.slip-sheet col.c-id { width: 12%; }
.slip-sheet col.c-foreign, .slip-sheet col.c-japanese { width: 11%; }
.slip-sheet col.c-amount { width: 21%; }
.slip-sheet col.c-pay { width: 13%; }
.slip-sheet col.c-split { width: 24%; }
.slip-sheet col.c-del { width: 8%; }

.slip-sheet th,
.slip-sheet td {
    border-right: 1px solid var(--paper-line);
    border-bottom: 1px solid var(--paper-line);
    padding: 0;
    height: 28px;
    white-space: nowrap;
    overflow: hidden;
}

.slip-sheet th:last-child,
.slip-sheet td:last-child {
    border-right: 0;
}

.slip-sheet th {
    position: -webkit-sticky;
    position: sticky;
    top: var(--hdr-h);
    z-index: 3;
    background: var(--paper-2);
    color: #2a2730;
    font-weight: 600;
    font-size: 11px;
    line-height: 1.2;
    padding: 3px 2px;
    text-align: center;
    white-space: normal;
}

.slip-sheet td {
    background: var(--paper);
    text-align: right;
}

.slip-sheet td.auto {
    background: var(--paper-3);
    color: #3a3740;
    padding: 0 4px;
}

.slip-sheet td.split {
    font-size: 11px;
    line-height: 1.25;
    padding: 2px 5px;
}

/* 「外」「日」は左にそろえ、数字は右にそろえる */
.slip-sheet .split-line {
    display: flex;
    justify-content: space-between;
    gap: 4px;
}

.slip-sheet .split-k {
    flex: none;
    color: #6a6672;
}

.slip-sheet .split-v {
    min-width: 0;
}

.slip-sheet tfoot .split-k {
    color: #3a3740;
}

.slip-sheet td input {
    width: 100%;
    min-width: 0;
    height: 100%;
    box-sizing: border-box;
    padding: 4px;
    font-size: 13px;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    background: transparent;
    color: var(--paper-text);
    border: 0;
    outline: none;
    text-align: right;
    border-radius: 0;
}

.slip-sheet td input:focus {
    outline: 2px solid #2a2730;
    outline-offset: -2px;
    background: #fff;
}

/* 行の色は2種類だけ: 黄＝要確認（推定・AI読み）、赤＝要修正（重複・0・未入力） */
.slip-sheet tr.row-flag td:not(.auto),
.slip-sheet tr.row-ai td:not(.auto) { background: #fff0b3; }
.slip-sheet tr.row-flag td.auto,
.slip-sheet tr.row-ai td.auto { background: #ecdd9e; }
.slip-sheet tr.row-needs td { background: #ffc9c9; }
.slip-sheet td.bad,
.slip-sheet tr.row-flag td.bad,
.slip-sheet tr.row-ai td.bad { background: #ffb3b3; }
.slip-sheet td.bad input { color: #7a0000; font-weight: 700; }

.slip-sheet tfoot td {
    position: -webkit-sticky;
    position: sticky;
    bottom: var(--bar-h);
    z-index: 2;
    background: var(--paper-2);
    font-weight: 700;
    text-align: right;
    padding: 0 4px;
    border-top: 2px solid #8a8578;
    font-size: 12px;
}

.slip-sheet tfoot td {
    border-bottom: 0;
}

.slip-sheet tfoot td.cnt {
    text-align: center;
    font-size: 11px;
}

.slip-sheet tfoot td.split {
    font-size: 11px;
    padding: 2px 4px;
}

/* 決済（現金／カード／QR）。タップで切り替え。現金は控えめ、カード・QRは太字で目立たせる */
.slip-sheet td.c-pay {
    text-align: center;
    padding: 0 2px;
}

.slip-pay {
    background: none;
    border: 1px solid #b9b4a7;
    color: #6a6670;
    border-radius: 6px;
    padding: 2px 0;
    width: 100%;
    font-size: 11px;
    line-height: 1.2;
    font-family: var(--font-body);
    cursor: pointer;
}

.slip-pay.on {
    border-color: #2a2730;
    color: #1a1820;
    font-weight: 700;
}

.slip-sheet td.del {
    text-align: center;
    padding: 0 2px;
}

.slip-del {
    background: none;
    border: 1px solid #b9b4a7;
    color: #5a5660;
    border-radius: 6px;
    padding: 1px 0;
    width: 100%;
    max-width: 28px;
    font-size: 13px;
    line-height: 1.2;
    font-family: inherit;
    cursor: pointer;
}

.slip-legend {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 0 6px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.slip-legend .sw {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 5px;
    vertical-align: -1px;
    border: 1px solid #888;
    border-radius: 2px;
}

.slip-legend .sw-edit { background: var(--paper); }
.slip-legend .sw-auto { background: var(--paper-3); }
.slip-legend .sw-flag { background: #fff0b3; }
.slip-legend .sw-needs { background: #ffc9c9; }

/* 画面下の結果バー（表ができたら常に表示・小さな文字） */
.slip-bar {
    position: -webkit-sticky;
    position: sticky;
    bottom: 0;
    z-index: 90;
    margin: 16px -16px 0;
    display: block;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
    background: var(--bg-primary);
    border-top: 1px solid var(--border-strong);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
}

.slip-bar-main {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px 8px;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    color: var(--text-secondary);
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-size: 10.5px;
    line-height: 1.25;
    cursor: pointer;
}

.bar-cell {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.bar-k {
    font-size: 9.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.bar-v {
    font-size: 11px;
    color: var(--text-primary);
    white-space: nowrap;
}

.bar-cell.key .bar-k {
    color: var(--text-secondary);
}

.bar-cell.key .bar-v {
    font-size: 12.5px;
    font-weight: 700;
}

.slip-bar-full {
    max-height: 45vh;
    overflow: auto;
    margin: 4px 0 0;
    padding: 8px 10px;
    border-top: 1px solid var(--border-glass);
    font-size: 11px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* ===== フッター（制作者・連絡先） ===== */
.site-footer {
    max-width: 980px;
    margin: 0 auto;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-glass);
    text-align: center;
    font-size: 0.72rem;
    line-height: 1.8;
    color: var(--text-muted);
}

.site-footer a {
    color: var(--text-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ===== 古い iOS（12 以前）向けの代替: flex の gap が効かないので余白で代用する =====
   inset が使えないブラウザ ≒ flex の gap も使えないブラウザ */
@supports not (inset: 0) {
    .slip-btn-row > * { margin: 0 8px 8px 0; }
    .slip-btn-row { margin-bottom: -8px; }
    .slip-warning li .w-dot { margin-right: 8px; }
    .slip-warning-key span { margin-right: 10px; }
    .slip-warning-key span .w-dot { margin-right: 4px; }
    .slip-legend span { margin-bottom: 2px; }
    .slip-field input { margin-top: 4px; }
    .today-day { margin-left: 8px; }
    .today-icon { margin-right: 8px; }
    .chk-item input { margin-right: 12px; }
    .header-title h1 { margin-right: 10px; }
    .category-tabs { margin: 0 -2.5px; }
    .tab { margin: 0 2.5px 5px; }
}

/* 買い物・クレカ・QR の未入力（表にした後）: 欄と見出しを赤で示す */
.slip-amounts.missing {
    border-color: var(--danger);
}

.slip-field.missing {
    color: var(--danger);
    font-weight: 700;
}

.slip-field.missing input {
    border: 2px solid var(--danger);
    background: #fff0f0;
}

.slip-field.missing input::placeholder {
    color: #c0392b;
    font-weight: 700;
}

.bar-cell.missing .bar-k,
.bar-cell.missing .bar-v {
    color: var(--danger);
    font-weight: 700;
}

/* ---- サーバー保存の状況（色は既存の3色だけ：注意＝黄／要修正＝赤／それ以外は無彩色） ---- */
.slip-sync {
    min-height: 1.2em;
    margin-top: 4px;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-muted);
}
.slip-sync.s-ok { color: var(--text-secondary); }
.slip-sync.s-warn { color: var(--warn); }
.slip-sync.s-fix { color: var(--danger); }
#syncActions:empty { display: none; }
.slip-btn-row .slip-btn.slip-btn-small { padding: 8px 12px; font-size: 0.8rem; }

/* 入力した人：金額の3欄の下に横いっぱい。名前なので左寄せ */
.slip-field-editor { grid-column: 1 / -1; }
.slip-field-editor input { text-align: left; font-family: var(--font-body); }

/* ---- 過去の伝票 ---- */
.slip-history { margin-top: 28px; }
.hist-list { margin-top: 10px; border-top: 1px solid var(--border-glass); }
.hist-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--border-glass);
    padding: 10px 2px;
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
}
.hist-top { display: flex; justify-content: space-between; align-items: baseline; }
.hist-date { font-weight: 700; font-size: 0.95rem; }
.hist-total { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 700; }
.hist-sub { margin-top: 2px; font-size: 0.75rem; color: var(--text-muted); }
.hist-sub .open { color: var(--warn); }
.hist-empty, .hist-msg { margin-top: 10px; font-size: 0.85rem; color: var(--text-muted); }
.hist-detail { margin-top: 12px; }
.hist-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.hist-title { font-weight: 700; }
.hist-meta { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 8px; line-height: 1.5; }
.hist-summary {
    white-space: pre-wrap;
    font-size: 0.82rem;
    line-height: 1.6;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}
.slip-sheet.ro td { padding: 0 5px; }
.slip-sheet.ro td.c-pay { text-align: center; font-size: 11px; }
.slip-sheet.ro td.c-pay.on { font-weight: 700; }
.hist-notes { margin-top: 14px; }
.hist-note {
    padding: 8px 10px;
    border-left: 3px solid var(--warn);
    background: var(--bg-card);
    margin-bottom: 6px;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
}
.hist-note-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.hist-form textarea, .hist-form input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    font-size: 15px;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--paper-text);
    border: 1px solid var(--paper-line);
    border-radius: 6px;
    margin-top: 6px;
}

/* ロックされた伝票：直せないが読めるように（iOS は disabled の文字を薄くするので色を戻す） */
.locked input:disabled {
    -webkit-text-fill-color: var(--paper-text);
    color: var(--paper-text);
    opacity: 1;
}
.locked button:disabled { opacity: 0.45; cursor: default; }
.slip-result-section.locked .slip-sheet td { background: var(--paper-3); }
