/* ===========================================================
   NOMITAI — 深夜のカウンター
   Figma Make「画面作成」v27 のデザインを素の CSS に翻案
   =========================================================== */

:root {
  --base:   #14100e;                 /* 背景 */
  --paper:  #e8e1d5;                 /* 主テキスト */
  --ash:    #8f857a;                 /* 副テキスト */
  --amber:  #c88a3c;                 /* 飲んだ／確定 */
  --neon:   #a83a2c;                 /* いつか飲む／削除 */

  --line:        rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.15);
  --line-soft:   rgba(255, 255, 255, 0.06);

  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans:  "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  --serif: "Noto Serif JP", "Hiragino Mincho ProN", serif;
  --display: "Anton", var(--sans);

  /* 現在のタブに応じたアクセント（app.js が切り替える） */
  --accent: var(--neon);

  --pad: 24px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--base);
}

body {
  font-family: var(--sans);
  color: var(--paper);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.mono { font-family: var(--mono); }

/* ---------- 画面の器 ---------- */
.app {
  position: relative;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(200, 138, 60, 0.07), transparent 60%),
    var(--base);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ===========================================================
   表紙
   =========================================================== */
.cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  padding: max(80px, env(safe-area-inset-top)) 24px 80px;
  text-align: center;
}

.cover-time {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--ash);
}

.cover-mid { display: block; }

.cover-logo {
  display: block;
  font-family: var(--display);
  font-size: clamp(56px, 20vw, 76px);
  line-height: 0.9;
  letter-spacing: 0.02em;
  color: var(--paper);
}

.cover-rule {
  display: block;
  width: 64px;
  height: 1px;
  margin: 22px auto 0;
  background: var(--amber);
  opacity: 0.55;
}

.cover-tagline {
  display: block;
  margin-top: 22px;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 2;
  color: var(--ash);
}

.cover-enter {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--amber);
}

/* ===========================================================
   共通ヘッダー
   =========================================================== */
.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-shrink: 0;
  padding: max(28px, env(safe-area-inset-top)) var(--pad) 0;
}

.wordmark {
  font-family: var(--display);
  font-size: 24px;
  letter-spacing: 0.025em;
  color: var(--paper);
}

.count,
.ledger-jp {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ash);
}

.ledger-jp {
  font-family: var(--serif);
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.1em;
  color: var(--paper);
}

/* ---------- タブ ---------- */
.tabs {
  display: flex;
  gap: 28px;
  flex-shrink: 0;
  margin-top: 22px;
  padding: 0 var(--pad);
  border-bottom: 1px solid var(--line-soft);
}

.tab {
  position: relative;
  padding-bottom: 12px;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 16px;
  color: rgba(143, 133, 122, 0.6);
  transition: color 0.18s;
}

.tab.active { color: var(--paper); }

.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

/* ---------- 一覧 ---------- */
.tabbody {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.tabtrack {
  display: flex;
  width: 200%;
  height: 100%;
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.tabtrack.dragging {
  transition: none;
}

.tabpane {
  width: 50%;
  height: 100%;
  overflow-y: auto;
  padding: 20px var(--pad) 140px;
  -webkit-overflow-scrolling: touch;
}

.section-label {
  margin: 0 0 16px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.25em;
  color: rgba(143, 133, 122, 0.7);
}

.section-label.plain { margin: 0; }

.list { display: flex; flex-direction: column; }

.card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 12px 0;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
}

.card:active { opacity: 0.6; }

.card-thumb {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line-soft);
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-thumb.blank {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 16px;
  color: rgba(143, 133, 122, 0.5);
}

.card-main { flex: 1 1 auto; min-width: 0; }

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 16px;
  color: var(--paper);
}

.card-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.card-title span:first-child {
  flex: 1 1 auto;
}

.card-star { flex-shrink: 0; color: var(--amber); font-size: 13px; }

.card-sub {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ash);
}

.card-sub .dim { color: rgba(143, 133, 122, 0.6); }

.card-chev {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 14px;
  color: rgba(143, 133, 122, 0.4);
}

.empty {
  margin: 40px 0 0;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 2.1;
  color: rgba(143, 133, 122, 0.75);
}

.empty.small { margin-top: 10px; font-size: 13px; }

/* ---------- 検索・絞り込み ---------- */
.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line-strong);
}

.search-icon { font-size: 13px; color: var(--ash); }

.sort-btn {
  flex-shrink: 0;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ash);
  white-space: nowrap;
}

.sort-btn:active { color: var(--amber); }

.searchbar input {
  flex: 1 1 auto;
  min-width: 0;
  background: none;
  border: 0;
  padding: 2px 0;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--paper);
}

.searchbar input::placeholder { color: rgba(143, 133, 122, 0.75); }
.searchbar input:focus { outline: none; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.sortrow {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 18px;
}

.filter {
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  font-size: 12px;
  color: rgba(232, 225, 213, 0.8);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filter.active {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--base);
}

/* ---------- FAB ---------- */
.fab {
  position: absolute;
  right: 24px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--base);
  font-size: 26px;
  font-weight: 300;
  line-height: 1;
  box-shadow: 0 12px 28px -10px rgba(0, 0, 0, 0.9);
  transition: transform 0.12s;
}

.fab:active { transform: scale(0.94); }

/* ---------- 下部ナビ ---------- */
.bottomnav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  padding: 12px var(--pad) calc(16px + env(safe-area-inset-bottom));
  background: var(--base);
  border-top: 1px solid var(--line-soft);
}

.navitem {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: rgba(143, 133, 122, 0.5);
  transition: color 0.15s;
}

.navitem.active { color: var(--amber); }
.navicon { font-family: var(--mono); font-size: 13px; }

/* ===========================================================
   帳簿
   =========================================================== */
.ledger-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 26px var(--pad) 120px;
}

.statgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  margin-bottom: 30px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 18px 22px;
}

.stat:nth-child(odd)  { border-right: 1px solid var(--line); }
.stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }

.stat-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ash);
}

.stat-val {
  font-family: var(--serif);
  font-weight: 900;
  font-size: 34px;
  line-height: 1;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

.stat-val i {
  font-style: normal;
  font-size: 12px;
  margin-left: 4px;
  color: var(--ash);
}

.seat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--line-soft);
}

.seat-val { display: flex; align-items: baseline; gap: 10px; }

.seat-val b {
  font-family: var(--serif);
  font-weight: 900;
  font-size: 19px;
  color: var(--amber);
}

.seat-val span { font-size: 11px; color: var(--ash); }

.bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 30px;
}

.bar-row {
  display: grid;
  grid-template-columns: 96px 1fr 28px;
  align-items: center;
  gap: 12px;
}

.bar-name {
  font-size: 13px;
  color: var(--paper);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-name.mono { font-size: 12px; letter-spacing: 0.04em; }

.bar-track { height: 3px; background: var(--line-soft); }

.bar-fill {
  height: 100%;
  background: rgba(255, 255, 255, 0.28);
}

.bar-fill.lead { background: var(--amber); }
.bar-fill.month { height: 100%; }

.bar-row.month .bar-track { height: 12px; }

.bar-count {
  font-family: var(--mono);
  font-size: 11px;
  text-align: right;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

/* ===========================================================
   フォーム
   =========================================================== */
.formbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  flex-shrink: 0;
  padding: max(28px, env(safe-area-inset-top)) var(--pad) 16px;
}

.formbar-cancel {
  justify-self: start;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ash);
}

.formbar-title {
  justify-self: center;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 17px;
  color: var(--paper);
}

.formbody {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--pad) 24px;
}

.photo-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 26px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
}

.photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-ph {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--ash);
}

.photo-ph-icon { font-size: 24px; line-height: 1; }
.photo-ph .mono { font-size: 10px; letter-spacing: 0.1em; }

.field { margin-bottom: 24px; }

.flabel {
  display: block;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--ash);
}

.finput {
  display: block;
  width: 100%;
  padding: 8px 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--paper);
  resize: none;
}

.finput::placeholder { color: rgba(143, 133, 122, 0.75); }
.finput:focus { outline: none; border-bottom-color: var(--amber); }

textarea.finput { line-height: 1.9; }

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

.daterow .finput {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 17px;
  letter-spacing: 0.04em;
}

/* ネイティブの日付ピッカーのアイコンを暗い背景で見えるように */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.55;
  cursor: pointer;
}

.quick {
  flex-shrink: 0;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  font-size: 13px;
  color: rgba(232, 225, 213, 0.85);
}

.quick.active {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--base);
}

.chiprow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.chiprow.tight { margin-top: 0; }

.chip {
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  font-size: 13px;
  color: rgba(232, 225, 213, 0.85);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip.mono { font-size: 12px; }

.chip.active {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--base);
}

.chip-add {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 4px;
  font-size: 13px;
  color: var(--amber);
}

.form-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.9;
  color: rgba(143, 133, 122, 0.7);
}

.formfoot,
.detailfoot {
  flex-shrink: 0;
  padding: 14px var(--pad) calc(20px + env(safe-area-inset-bottom));
  background: var(--base);
  border-top: 1px solid var(--line-soft);
}

.primary {
  display: block;
  width: 100%;
  padding: 15px;
  background: var(--amber);
  color: var(--base);
  font-family: var(--serif);
  font-weight: 900;
  font-size: 15px;
  transition: transform 0.12s;
}

.primary:active { transform: scale(0.99); }
.primary.wish { background: var(--neon); color: var(--paper); }

.ghost {
  flex: 1;
  padding: 13px;
  border: 1px solid var(--line-strong);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(232, 225, 213, 0.8);
}

.ghost.danger { border-color: var(--line); color: var(--neon); }
.ghost.accent { border-color: var(--amber); color: var(--amber); }

/* ===========================================================
   詳細
   =========================================================== */
.detail-kind {
  justify-self: center;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--amber);
}

.detail-kind.wish { color: var(--neon); }

.fav-btn {
  justify-self: end;
  font-size: 18px;
  line-height: 1;
  color: rgba(143, 133, 122, 0.45);
  transition: color 0.15s;
}

.fav-btn.on { color: var(--amber); }

.detailbody {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 24px;
}

.detail-photo {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: rgba(0, 0, 0, 0.45);
}

.detail-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 写真の下端をフェードさせ、タイトルを重ねる */
.detail-photo::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 55%;
  background: linear-gradient(to bottom, transparent, var(--base));
  pointer-events: none;
}

.detail-photo.blank {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: rgba(143, 133, 122, 0.6);
}

.detail-title {
  position: relative;
  margin: -34px var(--pad) 0;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 26px;
  line-height: 1.3;
  color: var(--paper);
  text-wrap: balance;
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 24px var(--pad) 0;
}

.meta-row { display: flex; align-items: baseline; gap: 16px; }

.meta-row dt {
  flex-shrink: 0;
  width: 40px;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ash);
}

.meta-row dd {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 14px;
  color: rgba(232, 225, 213, 0.9);
}

.meta-row dd.mono { font-size: 13px; letter-spacing: 0.02em; }

.detail-memo {
  margin: 26px var(--pad) 0;
  padding-left: 16px;
  border-left: 2px solid rgba(200, 138, 60, 0.4);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 2;
  color: rgba(232, 225, 213, 0.9);
  white-space: pre-wrap;
}

.detail-memo.muted {
  font-style: normal;
  color: rgba(143, 133, 122, 0.7);
}

.detail-subrow { display: flex; gap: 10px; margin-top: 10px; }

/* ===========================================================
   撮影
   =========================================================== */
[data-screen="camera"] {
  background: #080605;
  align-items: center;
  justify-content: space-between;
  padding: max(28px, env(safe-area-inset-top)) var(--pad) calc(40px + env(safe-area-inset-bottom));
}

.cam-close {
  align-self: flex-start;
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--ash);
}

.cam-frame {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 24px 0;
  border: 1px dashed rgba(200, 138, 60, 0.35);
}

.cam-frame .mono {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: rgba(143, 133, 122, 0.8);
}

.cam-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.shutter {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 2px var(--base), 0 0 0 4px rgba(232, 225, 213, 0.5);
  transition: transform 0.12s;
}

.shutter:active { transform: scale(0.92); }

.lib-link {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--amber);
  text-decoration: underline;
  text-underline-offset: 5px;
}

/* ===========================================================
   ダイアログ・トースト
   =========================================================== */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(0, 0, 0, 0.72);
}

.dialog {
  width: 100%;
  max-width: 320px;
  padding: 26px 24px 20px;
  background: #1c1714;
  border: 1px solid var(--line);
}

.dialog-title {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 16px;
  color: var(--paper);
}

.dialog-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--ash);
}

.dialog .finput { margin-top: 6px; }

.dialog-actions { display: flex; gap: 10px; margin-top: 22px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(112px + env(safe-area-inset-bottom));
  z-index: 50;
  transform: translate(-50%, 12px);
  max-width: calc(100% - 48px);
  padding: 11px 18px;
  background: var(--paper);
  color: var(--base);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s, transform 0.24s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

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