/* 防災ローリングストック */
:root {
  --bg: #0f1419;
  --surface: #1a222c;
  --surface2: #232d3a;
  --text: #e8eef4;
  --muted: #8b9cb3;
  --accent: #3d9cf0;
  --accent-hover: #5eb0f7;
  --danger: #e85d5d;
  --danger-bg: rgba(232, 93, 93, 0.12);
  --ok: #5ee6ad;
  --ok-border: #3ecf8e;
  --ok-bg: rgba(62, 207, 142, 0.12);
  --warn: #f0b429;
  --warn-bg: rgba(240, 180, 41, 0.14);
  --border: #2f3d4d;
  --radius: 12px;
  --tap: 44px;
  --font: "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #e8edf2;
    --surface: #ffffff;
    --surface2: #f0f3f7;
    --text: #1a2332;
    --muted: #5a6b7d;
    --border: #c5d0dc;
    --danger-bg: rgba(232, 93, 93, 0.1);
  }
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 1rem;
  border-radius: 10px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #061018;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

main {
  flex: 1;
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

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

.page-heading {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.table-list-toolbar-text {
  flex: 1 1 16rem;
  min-width: 0;
}

.table-list-lede {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  max-width: 40em;
}

.table-mode-hint {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* 狭い画面: 絞り・並び（カード表示の主導線） */
.list-filters {
  display: none;
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
}

.list-filters-legend {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.list-filters-sublabel {
  margin: 0.4rem 0 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
}

.list-filter-status {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  line-height: 1.4;
  font-weight: 500;
}

.filter-pill-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filter-pill-list .toolbar-pill {
  min-height: 2rem;
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
}

@media (max-width: 639px) {
  .list-filters {
    display: block;
  }
}

/* 直近削除の取り消し */
.undo-toast {
  position: fixed;
  z-index: 50;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(3.25rem + env(safe-area-inset-bottom, 0px));
  max-width: 32rem;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.undo-toast[hidden] {
  display: none !important;
}

.undo-toast-msg {
  font-size: 0.88rem;
  line-height: 1.4;
  flex: 1 1 12rem;
  min-width: 0;
}

.btn-undo {
  min-height: 2.25rem;
  padding: 0 0.75rem;
  font-size: 0.85rem;
}

@media (min-width: 640px) {
  .undo-toast {
    bottom: 1.25rem;
  }
}

.empty-cells-actions {
  margin: 0.75rem 0 0;
}

.empty-cells-note {
  display: inline-block;
  margin-left: 0.5rem;
  max-width: 18rem;
  vertical-align: middle;
  text-align: left;
}

/* 表ヘッダのカテゴリパネル用ピル、ほか */
.toolbar-pill {
  min-height: 2.15rem;
  max-width: 100%;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  text-align: left;
  word-break: break-word;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}

.toolbar-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.toolbar-pill.is-active,
.toolbar-pill[aria-pressed="true"] {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--accent) inset;
}

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

/* 表ラッパ（横スクロール・メニュー位置の基準） */
.table-wrap {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.stock-table {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table-list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.table-list-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.table-list-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex: 0 0 auto;
  align-self: center;
}

.selection-action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.selection-action-bar[hidden] {
  display: none !important;
}

.selection-action-bar-count {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.selection-action-bar-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.6;
}

/* 1列目は rem 固定、2〜7列目の % 合+1.9rem は表幅 100% と必ずしも一致しない（余剰再分配の余地あり）。
   列幅をユーザーが保存した場合、column-widths.js が各 col に style.width を与え、以下の % は無効化される。 */
.stock-table .col-cb {
  width: 1.9rem;
}
.stock-table .col-cat {
  width: min(8%, 7.25rem);
}
.stock-table .col-name {
  width: 24%;
}
.stock-table .col-qty {
  width: 8%;
}
.stock-table .col-rem {
  width: 10%;
}
.stock-table .col-exp {
  width: 16%;
}
.stock-table .col-url {
  width: 10%;
}

.stock-table caption {
  /* .sr-only when visible text is in .table-list-toolbar */
  caption-side: top;
  padding: 0;
  margin: 0;
  border: 0;
}

.stock-table th,
.stock-table td {
  padding: 0.5rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
  min-width: 0;
}

.stock-table th {
  background: var(--surface2);
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-weight: 600;
  position: relative;
}

/* クリックで絞り込み・並び替え（表ヘッダ） */
th.th-sort-header {
  padding: 0;
  vertical-align: bottom;
}

th.th-sort-header.is-inactive .th-header-btn {
  opacity: 0.85;
}

th.th-sort-header.th-sorted-asc .th-header-label,
th.th-sort-header.th-sorted-desc .th-header-label {
  color: var(--accent);
}

.th-header-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  width: 100%;
  min-height: 2.4rem;
  margin: 0;
  padding: 0.5rem 0.5rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  text-align: left;
  white-space: normal;
}

.th-header-btn:hover,
.th-header-btn:focus-visible {
  color: var(--accent);
  background: rgba(61, 156, 240, 0.1);
  outline: none;
}

.th-header-label {
  min-width: 0;
  word-break: break-word;
}

.th-header-sort {
  flex-shrink: 0;
  font-size: 0.6rem;
  line-height: 1;
  color: var(--accent);
  opacity: 0.95;
}

.th-category-popover {
  position: fixed;
  z-index: 30;
  left: 0;
  top: 0;
  max-width: min(100vw - 1rem, 22rem);
  padding: 0.65rem 0.75rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

.th-cat-popover-legend {
  margin: 0 0 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
}

.th-cat-popover-legend + .th-cat-popover-filters {
  margin-top: 0;
}

#th-cat-popover-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

#th-cat-popover-filters .toolbar-pill {
  min-height: 2rem;
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
}

.th-cat-popover-sort {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.th-cat-popover-sortbtn {
  flex: 1 1 8rem;
  min-height: 2.15rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}

.th-cat-popover-sortbtn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.th-cat-popover-sortbtn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--accent) inset;
}

/* 表頭セル左端: 前の列との境目をドラッグ（PC・640px+・pointer: fine 時は JS がハンドル挿入） */
.col-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  margin-left: -3px;
  z-index: 2;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
  box-sizing: border-box;
}

.col-resize-handle:hover {
  background: rgba(61, 156, 240, 0.2);
}

body.is-col-resizing {
  user-select: none;
  cursor: col-resize;
}

@media (max-width: 639px), (pointer: coarse) {
  .col-resize-handle {
    display: none !important;
    pointer-events: none;
  }
}

.stock-table tbody tr:hover {
  background: rgba(61, 156, 240, 0.06);
}

.stock-table tbody tr.is-near {
  background: var(--danger-bg);
  box-shadow: inset 3px 0 0 var(--danger);
}

.stock-table tbody tr.is-expired {
  background: rgba(232, 93, 93, 0.32);
  box-shadow: inset 3px 0 0 #c23a3a;
}

@media (prefers-color-scheme: light) {
  .stock-table tbody tr.is-expired {
    background: rgba(232, 93, 93, 0.22);
    box-shadow: inset 3px 0 0 #d04545;
  }
}

.stock-table tbody tr.is-expired:hover {
  background: rgba(232, 93, 93, 0.45);
}

@media (prefers-color-scheme: light) {
  .stock-table tbody tr.is-expired:hover {
    background: rgba(232, 93, 93, 0.32);
  }
}

.stock-table tbody tr.is-selected,
.stock-card.is-selected {
  background: rgba(61, 156, 240, 0.12) !important;
  box-shadow: inset 2px 0 0 var(--accent);
}

.th-cb,
.td-cb {
  width: 1.9rem;
  max-width: 1.9rem;
  box-sizing: border-box;
  text-align: center;
  padding: 0.45rem 0.2rem;
  vertical-align: middle;
}
.th-cb {
  position: relative;
}
.th-select-cb {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
  vertical-align: middle;
}
.row-select-cb {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
}
.new-item-row {
  background: rgba(61, 156, 240, 0.06);
}
.new-item-input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  box-sizing: border-box;
}
.new-item-placeholder {
  color: var(--muted);
}
.new-item-exp-block {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  min-width: 0;
}
.new-item-exp-block .new-item-input[type="date"] {
  flex: 1 1 auto;
  min-width: 0;
}
.btn-new-embed {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 0.65rem;
  font-size: 0.8rem;
  margin: 0;
  white-space: nowrap;
}
.stock-card-cbrow {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.stock-card-cbrow .card-cb {
  margin-top: 0.2rem;
  flex-shrink: 0;
}
.stock-card-cbtitle {
  flex: 1 1 auto;
  min-width: 0;
}

.stock-table tbody tr.is-empty-msg td {
  white-space: normal;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(1.06);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(232, 93, 93, 0.45);
}

.btn-danger-ghost:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

/* インライン編集セル */
.cell-editable {
  cursor: pointer;
}

/* 表の「タップ/クリックで編集」を示す軽い目印（ホバー下線に加えて） */
.stock-table .stock-data-row td.cell-editable .cell-value {
  box-shadow: 0 1px 0 0 rgba(139, 156, 179, 0.25);
  padding-bottom: 1px;
}

.stock-table td.cell-editable {
  max-width: 14rem;
}

.stock-table td.cell-editable[data-field="purchaseUrl"] {
  max-width: none;
}

.td-purchaseUrl {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.stock-table td.td-purchaseUrl .cell-value--shrink {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-purchaseUrl-external {
  flex: 0 0 auto;
  text-decoration: none;
  color: var(--accent);
  font-weight: 700;
  line-height: 1.2;
  padding: 0.1rem 0.2rem;
  border-radius: 4px;
}

.cell-purchaseUrl-external:hover {
  background: rgba(61, 156, 240, 0.12);
}

.stock-card-purchaseUrl {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  text-align: left;
}

.stock-table td.cell-editable:hover .cell-value {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.stock-card .cell-editable:hover .cell-value {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.td-remain {
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
}

.expiry-tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  border: 1px solid transparent;
}

.expiry-tag--expired {
  background: rgba(232, 93, 93, 0.22);
  color: #f5a8a8;
  border-color: rgba(232, 93, 93, 0.45);
}

.expiry-tag--today {
  background: rgba(232, 93, 93, 0.18);
  color: #ff9a9a;
  border-color: rgba(255, 120, 120, 0.45);
}

.expiry-tag--urgent {
  background: var(--danger-bg);
  color: #e8a0a0;
  border-color: rgba(232, 93, 93, 0.4);
}

.expiry-tag--soon {
  background: rgba(61, 156, 240, 0.16);
  color: #7ec4f0;
  border-color: rgba(61, 156, 240, 0.4);
}

.expiry-tag--ok {
  background: rgba(62, 207, 142, 0.2);
  color: #5ee6ad;
  border-color: rgba(62, 207, 142, 0.4);
}

.expiry-tag--long {
  background: rgba(139, 156, 179, 0.18);
  color: #b0bfd4;
  border-color: rgba(139, 156, 179, 0.4);
}

.cell-value {
  outline: none;
}

.cell-value:focus-visible {
  border-radius: 4px;
  box-shadow: 0 0 0 2px var(--accent);
}

.cell-control {
  width: 100%;
  min-width: 0;
  max-width: 12rem;
  min-height: 40px;
  padding: 0 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--surface2);
  color: var(--text);
  font-size: inherit;
  font-family: inherit;
}

.stock-table td.cell-editable[data-field="name"] .cell-control {
  max-width: 16rem;
}

.stock-table td.cell-editable[data-field="category"] .cell-control--category {
  max-width: 16rem;
}

/* フォーム共通 */
.form-page {
  max-width: 520px;
}
main.form-page--add {
  max-width: min(1100px, 100%);
  width: 100%;
}
.add-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: end;
  margin-top: 0.25rem;
}
.add-form-field-url {
  grid-column: 1 / -1;
}
.add-form-grid .form-field {
  margin-bottom: 0;
}
.add-form-note {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
}
@media (min-width: 900px) {
  .add-form-grid {
    grid-template-columns: 1.1fr 1.2fr 0.75fr 1.1fr 1.3fr;
  }
  .add-form-field-url {
    grid-column: auto;
  }
}
@media (max-width: 639px) {
  .add-form-grid {
    grid-template-columns: 1fr;
  }
  .add-form-field-url {
    grid-column: auto;
  }
  main.form-page--add {
    max-width: 520px;
  }
}

/* 外側をタップで戻る用に、フォーム以外の主領域を確保 */
main.form-page {
  min-height: min(100dvh - 7rem, 100%);
  padding: 0.5rem 1rem 1.5rem;
  box-sizing: border-box;
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.form-field {
  margin-bottom: 1rem;
}

.form-field-note {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
}

.form-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.form-field input,
.form-field select {
  width: 100%;
  min-height: var(--tap);
  padding: 0 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.form-actions--tight {
  margin-top: 0.75rem;
  gap: 0.5rem;
}

.code-inline {
  font-size: 0.9em;
  background: var(--surface2);
  padding: 0.12em 0.4em;
  border-radius: 4px;
  font-family: ui-monospace, Consolas, monospace;
  word-break: break-all;
}

.settings-sync-status.settings-error {
  color: var(--danger) !important;
  font-size: 0.88rem;
}

#sync-household-code {
  margin: 0.6rem 0 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
}

#sync-household-invite {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: ui-monospace, Consolas, monospace;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

/* 下部ナビ（アプリ風） */
.app-nav {
  display: flex;
  justify-content: space-around;
  padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
}

.app-nav a {
  flex: 1;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.app-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
}

/* 削除確認モーダル */
.modal[hidden] {
  display: none !important;
}

.modal:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.modal-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-body {
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-body--hint {
  margin-top: -0.5rem;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* カード一覧（狭い画面） */
.stock-cards {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}

.stock-cards-empty {
  margin: 0;
  text-align: center;
  padding: 2rem 1rem;
  line-height: 1.6;
}

.stock-cards-empty .btn {
  margin: 0.5rem 0.25rem 0;
  vertical-align: middle;
}

.stock-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
}

.stock-card.is-near {
  background: var(--danger-bg);
  box-shadow: inset 3px 0 0 var(--danger);
}

.stock-card.is-expired {
  background: rgba(232, 93, 93, 0.32);
  box-shadow: inset 3px 0 0 #c23a3a;
}

@media (prefers-color-scheme: light) {
  .stock-card.is-expired {
    background: rgba(232, 93, 93, 0.22);
    box-shadow: inset 3px 0 0 #d04545;
  }
}

.stock-card-name-block {
  margin-bottom: 0.5rem;
}

.stock-card-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.stock-card-tagline {
  margin: 0 0 0.5rem;
}

.stock-card-meta {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.stock-card-chip {
  display: inline;
}

.stock-card-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.stock-card-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.stock-card-actions {
  display: flex;
  justify-content: flex-end;
}

.form-fieldset-plain {
  border: none;
  padding: 0;
  margin: 0 0 1rem;
}

.form-fieldset-plain legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}

.checkbox-row:last-child {
  margin-bottom: 0;
}

.settings-feedback {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--ok);
}

@media (max-width: 639px) {
  .table-wrap {
    display: none !important;
  }

  .stock-cards {
    display: flex;
  }

  /* 入力行は表で編集：カード表示中でも表を一時的に出す */
  #main-stock.w-new-item .table-wrap {
    display: block !important;
  }

  #main-stock.w-new-item .stock-cards {
    display: none !important;
  }
}

@media (min-width: 768px) {
  .app-header h1 {
    font-size: 1.15rem;
  }

  .stock-table {
    font-size: 0.95rem;
  }

  .stock-table th,
  .stock-table td {
    padding: 0.75rem 0.9rem;
  }

  .stock-table .th-cb,
  .stock-table .td-cb {
    padding-left: 0.2rem;
    padding-right: 0.2rem;
  }
}
