:root {
    --bg: #eef2f0;
    --surface: #ffffff;
    --text: #14201a;
    --text-muted: #4b6356;
    --border: #d7e0da;
    --accent: #15803d;
    --accent-pressed: #166534;
    --accent-soft: #dcfce7;
    --deal: #c2410c;
    --deal-soft: #ffedd5;
    --danger: #b91c1c;
    --choice-bg: #f3f7f4;
    --shadow: 0 1px 2px rgba(20, 32, 26, 0.06);
    --radius: 12px;
    --app-max: 520px;
    --header-pad: 14px;
    --view-pad-x: 14px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --nav-h: 48px;
    --list-pad-x: 16px;
    --list-row-min-h: 52px;
    --list-font: 0.9375rem;
    --list-font-sub: 0.75rem;
    --list-line: 1px solid var(--border);
    --list-row-hover: #f5faf7;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    background:
        radial-gradient(1200px 420px at 50% -80px, rgba(21, 128, 61, 0.08), transparent 70%),
        var(--bg);
    color: var(--text);
    font-family:
        "Hiragino Sans",
        "Hiragino Kaku Gothic ProN",
        "Noto Sans JP",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

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

.cy-app {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    width: min(100%, var(--app-max));
    height: 100vh;
    height: 100dvh;
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    transform: translateY(var(--app-offset-y, 0px));
    margin: 0 auto;
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--border);
}

.cy-app.dialog-open {
    transform: none;
    overscroll-behavior: none;
    touch-action: manipulation;
}

html.cy-dialog-open,
html.cy-dialog-open body {
    overflow: hidden;
    overscroll-behavior: none;
}

.cy-header {
    flex-shrink: 0;
    padding: 8px var(--header-pad) 10px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.cy-header__top {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
}

.page-heading {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    line-height: 1.35;
    padding: 0 76px;
}

.cy-header__actions {
    position: absolute;
    right: -4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.icon-btn:hover {
    background: var(--choice-bg);
    color: var(--text);
}

.icon-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.page-lead {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-align: center;
    line-height: 1.4;
}

.cy-main {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
    background: var(--bg);
}

.view {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    padding: 0;
}

.view.is-active {
    display: flex;
}

.view-fixed {
    flex-shrink: 0;
    padding: 10px var(--view-pad-x) 0;
    background: var(--bg);
}

.view-body {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px var(--view-pad-x) 16px;
}

.view-body--solo {
    padding-top: 12px;
}

.view-actions {
    flex-shrink: 0;
    padding: 10px var(--view-pad-x) calc(10px + var(--safe-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.list-bleed {
    margin-left: calc(-1 * var(--view-pad-x));
    margin-right: calc(-1 * var(--view-pad-x));
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

/* 探すタブ：上部固定帯と一覧を隙間なく接続（kabu-lot の stocks-body 相当） */
.view-search .view-fixed {
    position: relative;
    z-index: 1;
    padding-bottom: 0;
}

.view-search .selection-bar {
    margin-bottom: 0;
}

.view-search .view-body {
    padding-top: 0;
}

.view-search .search-table.list-bleed {
    border-top: none;
}

.search-table__head {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: calc(100% + 2 * var(--view-pad-x));
    margin-left: calc(-1 * var(--view-pad-x));
    margin-right: calc(-1 * var(--view-pad-x));
    padding: 8px var(--list-pad-x);
    background: var(--bg);
    border-bottom: var(--list-line);
    color: var(--text-muted);
    font-size: var(--list-font-sub);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.02em;
    pointer-events: none;
}

.search-table__check-spacer {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    padding-top: 2px;
}

.search-table__head .product-row__body {
    gap: 0;
}

.search-table__head .product-row__name,
.search-table__head .price-value {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
}

.search-table__head .product-row__meta,
.search-table__head .price-tax {
    margin-top: 2px;
    font-size: 0.6875rem;
    font-weight: inherit;
    color: inherit;
}

.search-table__head .price-value {
    font-variant-numeric: tabular-nums;
}

.search-bar {
    margin-bottom: 8px;
}

.search-input,
.form-input,
.memo-title-input {
    width: 100%;
    font-size: 1rem;
    line-height: 1.4;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    min-height: 44px;
}

.search-input:focus,
.form-input:focus,
.memo-title-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.selection-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-bottom: 8px;
    min-height: 36px;
}

.selection-bar__meta {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.selection-bar__count {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent-pressed);
    white-space: nowrap;
}

#memo-create-from-selection {
    margin-left: auto;
    flex: 0 0 auto;
}

#records-bulk-delete {
    margin-left: auto;
    flex: 0 0 auto;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-text,
.btn-sm {
    font: inherit;
    cursor: pointer;
    border-radius: 10px;
    min-height: 44px;
    padding: 0 14px;
    border: none;
}

.btn-sm {
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.8125rem;
    font-weight: 700;
    border-radius: 8px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.btn-primary:hover {
    background: var(--accent-pressed);
}

.btn-secondary {
    background: var(--choice-bg);
    color: var(--text);
    font-weight: 600;
    border: 1px solid var(--border);
}

.btn-danger {
    background: #fef2f2;
    color: var(--danger);
    font-weight: 700;
    border: 1px solid #fecaca;
}

.btn-danger:hover {
    background: #fee2e2;
}

.btn-text {
    background: transparent;
    color: var(--accent);
    font-weight: 700;
    min-height: 36px;
    padding: 0 6px;
}

.btn-danger-text {
    color: var(--danger);
}

.btn-block {
    width: 100%;
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-danger:focus-visible,
.btn-text:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Empty */
.empty-state {
    text-align: center;
    padding: 28px 12px 20px;
}

.empty-state__title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.empty-state__text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.55;
}

/* Lists */
.product-row,
.record-row,
.memo-row,
.entity-item {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    min-height: var(--list-row-min-h);
    padding: 10px var(--list-pad-x);
    border: none;
    border-bottom: var(--list-line);
    background: var(--surface);
    color: inherit;
    text-align: left;
    font: inherit;
}

.product-row {
    align-items: flex-start;
}

.product-row:last-child,
.record-row:last-child,
.memo-row:last-child,
.entity-item:last-child {
    border-bottom: none;
}

.product-row:hover,
.record-row:hover,
.memo-row:hover {
    background: var(--list-row-hover);
}

.product-row,
.record-row {
    cursor: pointer;
}

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

.product-row__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.product-row__price {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    min-width: 4.5rem;
}

.product-row__hint {
    color: var(--accent);
    font-weight: 700;
}

.product-row__stores {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.store-pick {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--choice-bg);
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 700;
    font-family: inherit;
    line-height: 1.3;
    cursor: pointer;
}

.store-pick:hover {
    border-color: var(--accent);
}

.store-pick:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.store-pick.is-selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-pressed);
}

.price-tax {
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.2;
}

.row-actions {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    align-self: center;
    gap: 0;
}

.row-icon-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.row-icon-btn:hover {
    background: var(--choice-bg);
    color: var(--text);
}

.row-icon-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.row-icon-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.row-icon-btn--danger:hover {
    background: #fef2f2;
    color: var(--danger);
}

.row-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.row-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.product-row__check {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    padding-top: 2px;
}

.product-row__check input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.product-row__main,
.record-row__main,
.memo-row__main {
    flex: 1;
    min-width: 0;
}

button.memo-row__main {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

button.memo-row__main:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

.product-row__name,
.record-row__name,
.memo-row__title {
    font-size: var(--list-font);
    font-weight: 700;
    line-height: 1.35;
}

.name-scroll-wrap {
    position: relative;
    min-width: 0;
}

.name-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    white-space: nowrap;
}

.name-scroll::-webkit-scrollbar {
    display: none;
}

.name-scroll-wrap::before,
.name-scroll-wrap::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 1;
}

.name-scroll-wrap::before {
    left: 0;
    background: linear-gradient(
        to right,
        var(--name-fade-from, var(--surface)) 0%,
        transparent 100%
    );
}

.name-scroll-wrap::after {
    right: 0;
    background: linear-gradient(
        to left,
        var(--name-fade-from, var(--surface)) 0%,
        transparent 100%
    );
}

.name-scroll-wrap.can-scroll-left::before,
.name-scroll-wrap.can-scroll-right::after {
    opacity: 1;
}

.product-row__meta,
.record-row__meta,
.memo-row__meta {
    margin-top: 2px;
    font-size: var(--list-font-sub);
    color: var(--text-muted);
    line-height: 1.4;
}

.price-value {
    font-size: 1rem;
    font-weight: 800;
    color: var(--deal);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}

/* Inline edit panel */
.record-row {
    flex-wrap: wrap;
}

.record-row.is-editing {
    background: var(--choice-bg);
    --name-fade-from: var(--choice-bg);
}

.record-inline {
    flex: 1 1 100%;
    display: grid;
    gap: 8px;
    padding: 0 0 10px;
    border-bottom: var(--list-line);
}

.record-inline .form-label {
    margin: 0;
}

.record-inline__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.record-row__check {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.record-row__check input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/* Memo / shopping list */
.memo-title-input {
    font-size: 1.125rem;
    font-weight: 700;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding-left: 0;
    padding-right: 0;
    background: transparent;
    margin-bottom: 8px;
}

.memo-text {
    width: 100%;
    min-height: 4.5rem;
    resize: vertical;
    font-size: 1rem;
    line-height: 1.5;
    padding: 8px 0;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    margin-bottom: 12px;
}

.memo-text:focus {
    outline: none;
    border-bottom-color: var(--accent);
}

.memo-stores {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.memo-store__title {
    margin: 0 0 6px;
    padding: 0 2px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.memo-store__list {
    margin-bottom: 0;
}

.memo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: var(--list-row-min-h);
    padding: 8px var(--list-pad-x);
    border-bottom: var(--list-line);
}

.memo-item:last-child {
    border-bottom: none;
}

.memo-item .row-actions {
    flex: 0 0 auto;
    align-self: center;
}

.memo-item .product-row__price {
    margin-left: auto;
}

.memo-item__main {
    flex: 1;
    min-width: 0;
}

.memo-item__name {
    font-size: var(--list-font);
    font-weight: 600;
    line-height: 1.35;
}

.memo-item__meta {
    font-size: var(--list-font-sub);
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.35;
}

.memo-item__price {
    flex: 0 0 auto;
    font-size: 1rem;
    font-weight: 800;
    color: var(--deal);
    font-variant-numeric: tabular-nums;
}

.detail-top {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px var(--view-pad-x);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.detail-top--center {
    position: relative;
}

.detail-top__spacer {
    width: 52px;
    flex-shrink: 0;
}

.view-memo-detail {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: var(--bg);
}

.view-memo-detail.is-active {
    display: flex;
}

.memo-detail-actions {
    flex-shrink: 0;
    padding: 10px var(--view-pad-x) calc(10px + var(--safe-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
}

/* Price form overlay */
.view-price-form {
    position: absolute;
    inset: 0;
    z-index: 6;
    background: var(--bg);
}

.view-price-form.is-active {
    display: flex;
}

.price-form-top__title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
    pointer-events: none;
    max-width: calc(100% - 120px);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.price-form {
    padding-top: 10px;
}

.price-form-group {
    background: var(--surface);
    border-top: var(--list-line);
    border-bottom: var(--list-line);
}

.price-form-field {
    position: relative;
    border-bottom: var(--list-line);
}

.price-form-field:last-child {
    border-bottom: none;
}

.price-form-field.ac-field:focus-within {
    z-index: 8;
}

.price-form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--list-row-min-h);
    padding: 0 var(--list-pad-x);
}

.price-form-row__label {
    flex: 0 0 5.5em;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.35;
}

.price-form-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    border: none;
    border-radius: 0;
    background: transparent;
    font-size: 1rem;
    line-height: 1.4;
    color: var(--text);
    padding: 10px 0;
    min-height: 44px;
    text-align: left;
}

.price-form-input::placeholder {
    color: #8a9b90;
    text-align: left;
}

.price-form-input:focus {
    outline: none;
}

.price-form-row__control {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}

.price-form-row__control--date {
    flex-wrap: nowrap;
    gap: 4px;
}

.price-form-row__control--date .price-form-input[type='date'] {
    flex: 0 0 auto;
    width: 10.25rem;
    max-width: calc(100% - 3.5rem);
    min-width: 8.75rem;
    padding-right: 0;
}

.price-form-row__control--date .weekday-inline {
    flex: 0 0 auto;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.4;
    color: var(--text);
    white-space: nowrap;
}

.price-form-row__control--date .weekday-inline:empty {
    display: none;
}

.price-form-row--tax .price-form-row__control {
    justify-content: flex-start;
}

.price-form-row--tax .choice-row {
    flex: 1;
    justify-content: flex-start;
}

.price-form-row--tax .choice-chip {
    flex: 0 1 auto;
    min-width: 72px;
    min-height: 36px;
    font-size: 0.8125rem;
}

.price-form-field__error {
    margin: 0;
    padding: 0 var(--list-pad-x) 8px calc(var(--list-pad-x) + 5.5em + 12px);
}

.price-form-field.ac-field .ac-list {
    left: calc(var(--list-pad-x) + 5.5em + 12px);
    right: var(--list-pad-x);
    top: calc(100% - 1px);
}

.price-form-hint {
    margin: 10px var(--list-pad-x) 0;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.price-form-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px var(--view-pad-x) calc(10px + var(--safe-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.price-form-actions__spacer {
    flex: 1 1 auto;
    min-width: 8px;
}

.price-form-actions .row-icon-btn[hidden] {
    display: none !important;
}

.cy-app.price-form-open .cy-header,
.cy-app.price-form-open .bottom-nav,
.cy-app.price-form-open .view-actions {
    display: none;
}

.memo-add-overlay {
    position: absolute;
    inset: 0;
    z-index: 45;
    background: rgba(15, 23, 42, 0.4);
}

.memo-add-sheet {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    width: min(100%, 360px);
    background: var(--surface);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.22s ease;
    display: flex;
    flex-direction: column;
}

.memo-add-sheet.is-open {
    transform: translateX(0);
}

.memo-add-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.memo-add-sheet__title {
    font-size: 1.0625rem;
    font-weight: 700;
}

.memo-add-sheet__search {
    flex-shrink: 0;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

.memo-add-sheet__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.memo-add-sheet__footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px calc(10px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.memo-add-sheet__count {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-muted);
}

.memo-add-sheet__footer .btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.cy-app.detail-open .bottom-nav,
.cy-app.keyboard-open .bottom-nav {
    display: none;
}

.cy-app.detail-open .view-actions {
    display: none;
}

.cy-app.record-edit-open #view-records .view-actions {
    display: none;
}

/* Guide / footer */
.cy-guide {
    margin-top: 20px;
    padding: 4px 2px 8px;
    color: var(--text-muted);
    font-size: 0.8125rem;
    line-height: 1.65;
}

.cy-guide__title,
.cy-guide__heading {
    color: var(--text);
    font-size: 0.9375rem;
    font-weight: 700;
    margin: 16px 0 8px;
}

.cy-guide__title {
    margin-top: 8px;
}

.cy-guide__list,
.cy-guide__steps {
    padding-left: 1.2em;
    margin-bottom: 8px;
}

.cy-guide__list li,
.cy-guide__steps li {
    margin-bottom: 4px;
}

.cy-guide__faq-item {
    border-top: 1px solid var(--border);
    padding: 8px 0;
}

.cy-guide__faq-item summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text);
    list-style: none;
}

.cy-guide__faq-item summary::-webkit-details-marker {
    display: none;
}

.cy-guide__faq-item p {
    margin-top: 6px;
}

.cy-footer {
    margin-top: 20px;
    padding-bottom: 8px;
    text-align: center;
}

.cy-footer__links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.cy-footer__links a {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cy-footer__note {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

/* Bottom nav */
.bottom-nav {
    flex-shrink: 0;
    display: flex;
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding-bottom: var(--safe-bottom);
}

.bottom-nav__btn {
    flex: 1;
    min-height: var(--nav-h);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
}

.bottom-nav__btn.is-active {
    color: var(--accent);
}

.bottom-nav__btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Settings */
.settings-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    background: rgba(15, 23, 42, 0.4);
}

.settings-sheet {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    width: min(100%, 360px);
    background: var(--surface);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.22s ease;
    display: flex;
    flex-direction: column;
}

.settings-sheet.is-open {
    transform: translateX(0);
}

.settings-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.settings-sheet__title {
    font-size: 1.0625rem;
    font-weight: 700;
}

.settings-sheet__body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 24px;
    -webkit-overflow-scrolling: touch;
}

.settings-section {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.settings-section__title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.settings-section .btn-block + .btn-block {
    margin-top: 8px;
}

.settings-note,
.field-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.65;
    margin-bottom: 10px;
}

.entity-list,
.sale-label-list {
    list-style: none;
    margin-bottom: 10px;
}

.entity-item {
    padding-left: 0;
    padding-right: 0;
}

.entity-item__name {
    flex: 1;
    min-width: 0;
    font-size: 0.875rem;
    font-weight: 600;
}

.entity-item__actions {
    display: flex;
    gap: 4px;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-form .form-input {
    flex: 1;
    min-width: 0;
}

.inline-form .btn-secondary {
    flex: 0 0 auto;
    min-height: 44px;
}

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

.record-inline .ac-field--inline {
    position: relative;
    flex: 1;
    min-width: 0;
}

.choice-chip {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--choice-bg);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.875rem;
}

.choice-chip:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-pressed);
}

.choice-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.sale-label-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 40px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

/* Autocomplete */
.ac-field {
    position: relative;
    z-index: 1;
}

.ac-field:focus-within {
    z-index: 8;
}

.ac-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% - 2px);
    z-index: 9;
    max-height: 180px;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 4px 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.ac-list[hidden] {
    display: none !important;
}

.ac-list button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: none;
    background: transparent;
    font: inherit;
    font-size: 0.9375rem;
    color: var(--text);
    cursor: pointer;
    min-height: 44px;
}

.ac-list button:hover,
.ac-list button.is-active {
    background: var(--accent-soft);
}

.field-error {
    margin-top: 4px;
    margin-bottom: 4px;
    color: var(--danger);
    font-size: 0.75rem;
    font-weight: 600;
}

.form-label__control {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-label__control .form-input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
}

/* date は SE 幅でも折り返さず、曜日チップを右に固定 */
#store-form .form-label--date .form-label__control {
    flex-wrap: nowrap;
}

#store-form .form-label--date input[type='date'] {
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
}

.form-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.form-label__text {
    line-height: 1.35;
}

/* ダイアログ内フォーム：ラベルと入力を1行に（高さ圧縮） */
#store-form .form-label,
#product-form .form-label {
    flex-direction: row;
    align-items: center;
    gap: 10px 12px;
}

#store-form .form-label__text,
#product-form .form-label__text {
    flex: 0 0 5.5em;
    width: 5.5em;
}

#store-form .form-label .form-input,
#product-form .form-label .form-input,
#store-form .form-label .choice-row,
#store-form .form-label .form-label__control {
    flex: 1;
    min-width: 0;
    width: auto;
}

#store-form .field-error,
#product-form .field-error {
    margin-top: -4px;
    margin-bottom: 8px;
    margin-left: calc(5.5em + 12px);
}

.form-fieldset {
    border: none;
    margin: 0 0 10px;
    padding: 0;
}

.form-fieldset legend {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* Dialogs */
.form-dialog,
.confirm-dialog {
    /* position は指定しない（UA の dialog 中央寄せを維持する） */
    border: none;
    border-radius: 16px;
    padding: 0;
    margin: auto;
    width: min(calc(100% - 24px), 440px);
    max-height: min(90dvh, 720px);
    max-height: min(calc(var(--app-height, 100dvh) - 24px), 720px);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
}

/* キーボード表示中の上寄せは JS（visualViewport ピン留め）に任せる */

.form-dialog::backdrop,
.confirm-dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
    touch-action: none;
    overscroll-behavior: none;
}

.form-dialog__form,
.confirm-form {
    padding: 20px 18px 18px;
    overflow-y: auto;
    max-height: min(90dvh, 720px);
    max-height: min(calc(var(--app-height, 100dvh) - 24px), 720px);
}

/*
  固定フッター付きフォーム:
  dialog 自体に display:flex を当てると iOS Safari で中身が描画されず
  ::backdrop だけ見えることがあるため、flex は内側の form に閉じ込める。
*/
.form-dialog[open]:has(> .form-dialog__form--fixed-actions) {
    overflow: hidden;
}

.form-dialog__form--fixed-actions {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: 100%;
    max-height: min(90dvh, 720px);
    max-height: min(calc(var(--app-height, 100dvh) - 24px), 720px);
    padding: 0;
    overflow: hidden;
}

.form-dialog__header {
    flex-shrink: 0;
    padding: 20px 18px 0;
    background: var(--surface);
}

.form-dialog h2,
.confirm-dialog h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 14px;
}

.form-dialog__header h2 {
    margin-bottom: 8px;
}

.form-dialog__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 18px 16px;
}

.form-dialog__form--fixed-actions > .form-dialog__actions {
    flex-shrink: 0;
    margin-top: 0;
    padding: 12px 18px calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.form-dialog__actions,
.confirm-dialog__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    margin-top: 8px;
}

.form-dialog__actions-spacer {
    flex: 1 1 auto;
    min-width: 8px;
}

.form-dialog__actions .btn-danger[hidden],
.form-dialog__actions .row-icon-btn[hidden] {
    display: none !important;
}

.confirm-dialog__body {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Toast */
.app-toast {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: calc(100% - 32px);
    max-width: 22rem;
    padding: 12px 10px 12px 16px;
    border-radius: 10px;
    background: #1f2937;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.45;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.98);
    pointer-events: none;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
}

.app-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.app-toast__message {
    flex: 1;
    margin: 0;
    min-width: 0;
}

.app-toast__close {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
}

@media (min-width: 560px) {
    :root {
        --view-pad-x: 18px;
        --list-pad-x: 18px;
    }

    .page-heading {
        font-size: 1.0625rem;
    }
}
