:root {
  --navy: #163250;
  --navy-d: #0e2238;
  --terra: #c24e28;
  --terra-d: #9a391c;
  --gold: #c4a46a;
  --ink: #1c2128;
  --muted: #66707a;
  --bg: #efeae3;
  --paper: #fffcf8;
  --line: rgba(22, 50, 80, .1);
  --ok: #217a48;
  --warn: #c43b2c;
  --rest: #6b7380;
  --radius: 18px;
  --tab-h: 72px;
  --safe: env(safe-area-inset-bottom, 0px);
  --shadow: 0 10px 28px rgba(22, 50, 80, .07);
  --shadow-lg: 0 18px 50px rgba(22, 50, 80, .12);
  --ease: .18s ease;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", sans-serif;
  background:
    radial-gradient(900px 420px at 0% -8%, rgba(194, 78, 40, .08), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(22, 50, 80, .08), transparent 50%),
    var(--bg);
  color: var(--ink);
  line-height: 1.5;
  padding-bottom: calc(var(--tab-h) + var(--safe) + 18px);
  min-height: 100dvh;
}
a { color: var(--navy); }
button, input, select, textarea { font: inherit; }
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: rgba(255, 252, 248, .88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
  color: var(--navy);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--navy);
  text-decoration: none;
  font-weight: 800;
  font-size: .92rem;
  line-height: 1.25;
  min-width: 0;
  flex: 1;
}
.brand-text { min-width: 0; }
.brand-mark {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(145deg, #e07a4a, var(--terra) 55%, #8d3118);
  box-shadow: 0 6px 14px rgba(194, 78, 40, .28);
}
.top-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.account-chip, .role-chip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}
.account-chip {
  max-width: 28vw;
  color: var(--navy);
  text-decoration: none;
  background: rgba(22, 50, 80, .06);
}
.role-chip.owner { background: #e5f6eb; color: var(--ok); }
.role-chip.tax { background: #e8eef6; color: var(--navy); }
.logout {
  color: #fff;
  text-decoration: none;
  background: var(--navy);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
}
.main { padding: 16px; max-width: 820px; margin: 0 auto; }
.page-title { margin: 4px 0 .45rem; font-size: 1.4rem; display: flex; gap: 10px; align-items: center; letter-spacing: -.02em; }
.page-title .mark {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--navy), #2a4d73);
  color: #fff;
  display: grid; place-items: center;
  font-size: .9rem;
  box-shadow: var(--shadow);
}
h1 { font-size: 1.28rem; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.02rem; margin: 0 0 .55rem; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: .6rem 0 .3rem; }
.lead, .hint, .muted { color: var(--muted); }
.lead { margin: 0 0 14px; }
.hint { font-size: .9rem; }
.err { color: var(--warn); font-weight: 700; }
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}
.form label, .form fieldset { display: block; margin: 12px 0; }
.form input, .form select, .form textarea {
  width: 100%;
  margin-top: 6px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font: inherit;
  font-size: 16px;
  background: #fff;
  color: var(--ink);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: rgba(22, 50, 80, .35);
  box-shadow: 0 0 0 4px rgba(22, 50, 80, .1);
}
.form input[type="checkbox"] {
  width: 1.25rem; height: 1.25rem; margin: 0; padding: 0; flex: 0 0 auto; accent-color: var(--navy);
}
.choice { display: flex; align-items: center; gap: 10px; }
.btn, .ghost, button { font: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: var(--navy); color: #fff;
  padding: 14px 18px; border-radius: 14px; text-decoration: none; font-weight: 700;
  box-shadow: 0 8px 18px rgba(22, 50, 80, .18);
}
.btn.primary { background: var(--terra); box-shadow: 0 8px 18px rgba(194, 78, 40, .25); }
.btn.wide, .ghost-btn.wide { width: 100%; }
.ghost, .ghost-btn {
  background: rgba(255,255,255,.7);
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: none;
}
.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.date-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px;
}
.date-row h1 { text-align: center; flex: 1; }
.date-row .ghost {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  padding: 0; font-size: 1.05rem;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.banner {
  padding: 12px 14px; border-radius: 14px; font-weight: 700; margin-bottom: 12px;
}
.banner.ok { background: #e5f6eb; color: var(--ok); }
.banner.warn { background: #fde8e4; color: var(--warn); }
.banner.miss { background: #fff1d6; color: #8a5a12; }
.flash {
  padding: 11px 16px; text-align: center; font-weight: 700;
  position: sticky; top: 0; z-index: 21;
}
.flash.ok { background: #e5f6eb; color: var(--ok); }
.flash.error, .flash.err { background: #fde8e4; color: var(--warn); }
.tabs {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + var(--safe));
  height: 64px;
  padding: 0;
  display: grid;
  background: rgba(255, 252, 248, .92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}
.tabs-5 { grid-template-columns: repeat(5, 1fr); }
.tabs-4 { grid-template-columns: repeat(4, 1fr); }
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-weight: 700; font-size: .72rem;
  border-radius: 18px; margin: 6px 4px;
}
.tabs a svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.tabs a.on { color: var(--navy); background: rgba(22, 50, 80, .08); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.save-bar { position: sticky; bottom: calc(var(--tab-h) + var(--safe) + 10px); z-index: 5; }
.save-bar .btn { box-shadow: 0 12px 28px rgba(194, 78, 40, .32); }

.filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}
.filter-bar input, .filter-bar select, .filter-bar button {
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  font: inherit;
  font-size: 16px;
}
.filter-bar input[type="search"] { grid-column: 1 / -1; }
.visit-list { display: grid; gap: 12px; }
.visit-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  background: var(--paper);
  border-radius: 18px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.visit-card .cover {
  width: 96px; height: 100%; min-height: 96px;
  object-fit: cover; background: #ddd;
}
.visit-card .cover.none {
  display: grid; place-items: center;
  font-size: .75rem; color: var(--muted); background: #ece7e0;
}
.visit-body { padding: 10px 12px 10px 0; }
.visit-meta { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--muted); }
.visit-body strong { display: block; margin: 4px 0; }
.visit-body p { margin: 0; font-size: .9rem; color: var(--muted); }
.visit-foot { display: flex; gap: 10px; margin-top: 6px; font-size: .8rem; color: var(--navy); font-weight: 700; }
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
}
.pill.ok { background: #e5f6eb; color: var(--ok); }
.pill.draft { background: #eceff3; color: var(--rest); }

.kv { display: grid; grid-template-columns: 7.5rem 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; }
.pre { white-space: pre-wrap; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.score-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.score-table th { text-align: left; font-weight: 600; padding: 6px 8px 6px 0; }
.score-table td { padding: 6px 8px; vertical-align: top; }
.score-table .num { white-space: nowrap; font-weight: 700; }
.dish-view { padding: 10px 0; border-top: 1px solid var(--line); }
.dish-view:first-of-type { border-top: 0; }
.mini-scores { font-size: .85rem; color: var(--muted); }
blockquote {
  margin: 8px 0;
  padding: 10px 12px;
  background: #f6f2ec;
  border-radius: 12px;
}
blockquote p { margin: 4px 0 0; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}
.photo-grid figure {
  margin: 0;
  background: #f7f4ef;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
}
.photo-grid img {
  width: 100%; height: 140px; object-fit: cover;
  border-radius: 12px; background: #ddd;
}
.photo-grid figcaption { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.photo-grid label { display: block; margin: 8px 0 0; font-size: .82rem; font-weight: 700; }
.photo-grid select, .photo-grid input {
  width: 100%;
  margin-top: 4px;
  padding: 10px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  font-size: 16px;
  background: #fff;
}
.photo-grid .js-photo-del,
.photo-grid .js-photo-unassign { margin-top: 8px; }
.dish-photo-block {
  margin: 12px 0;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fff;
}
.dish-photo-label {
  margin: 0 0 8px;
  font-size: .85rem;
  font-weight: 800;
  color: var(--navy);
}
.dish-photos {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  margin-bottom: 8px;
}
.dish-photos:empty { display: none; }
.dish-photo-pick {
  display: block;
  width: 100%;
  text-align: center;
  margin: 0;
}
.dish-view .dish-photos { margin: 10px 0; }

.score {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.score-opt {
  position: relative;
  cursor: pointer;
}
.score-opt input { position: absolute; opacity: 0; pointer-events: none; }
.score-opt span {
  display: grid; place-items: center;
  min-width: 36px; height: 36px;
  padding: 0 8px;
  border-radius: 10px;
  background: rgba(22, 50, 80, .06);
  color: var(--muted);
  font-weight: 700;
  font-size: .85rem;
}
.score-opt:has(input:checked) span,
.score-opt.on span {
  background: var(--navy);
  color: #fff;
}
.score-opt:has(input:not(:checked)) span {
  background: rgba(22, 50, 80, .06);
  color: var(--muted);
}
.score-row { padding: 12px 0; border-top: 1px solid var(--line); }
.score-row:first-of-type { border-top: 0; }
.score-lab small { display: block; color: var(--muted); font-weight: 400; font-size: .8rem; }
.note-fold { margin-top: 8px; }
.note-fold summary {
  cursor: pointer;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
  list-style: none;
  width: fit-content;
}
.note-fold summary::-webkit-details-marker { display: none; }
.note-fold summary::before { content: "＋ "; }
.note-fold[open] summary::before { content: "− "; }
.note-fold input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  font-size: 16px;
}

.repeat-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin: 10px 0;
  background: #f7f4ef;
}
.dish-scores { display: grid; gap: 8px; margin: 8px 0; }
.dish-scores > div span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.comment-row { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.dining-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 4px;
}
.form .dining-opt {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  margin: 0;
  padding: 16px 10px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  overflow: hidden;
}
.form .dining-opt input,
.form .dining-opt input[type="radio"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  box-shadow: none;
  background: transparent;
}
.form .dining-opt span {
  display: block;
  width: 100%;
  text-align: center;
  line-height: 1.35;
  pointer-events: none;
}
.form .dining-opt:has(input:checked),
.form .dining-opt.on {
  border-color: var(--navy);
  background: rgba(22, 50, 80, .08);
  color: var(--navy);
}
#visit-form:not(.dining-dinein):not(.dining-takeout) .after-choice,
#visit-form:not(:has([name="dining_style"]:checked)) .after-choice,
#visit-form:not(.dining-dinein):not(.dining-takeout) ~ .after-choice,
#visit-form:not(:has([name="dining_style"]:checked)) ~ .after-choice {
  display: none;
}
#visit-form.dining-takeout .only-dinein,
#visit-form:has([name="dining_style"][value="takeout"]:checked) .only-dinein { display: none; }
#visit-form.dining-dinein .only-takeout,
#visit-form:has([name="dining_style"][value="dinein"]:checked) .only-takeout { display: none; }
.jump {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px;
}
.jump a {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 700;
}
.photo-pick { position: relative; overflow: hidden; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.danger-zone { margin: 24px 0 8px; text-align: center; }
.row-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.login-id-now {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-radius: 14px;
  background: rgba(22, 50, 80, .05); margin: 8px 0 12px;
}
.cal {
  width: 100%; border-collapse: collapse;
  background: var(--paper); border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow);
}
.cal th { font-size: .8rem; color: var(--muted); padding: 10px 6px; font-weight: 700; }
.cal td { padding: 5px; text-align: center; }
.day {
  display: grid; place-items: center; width: 42px; height: 42px; margin: 0 auto;
  border-radius: 14px; text-decoration: none; color: var(--ink); font-weight: 700;
  position: relative;
}
.day.ok { background: #d8f0e0; color: var(--ok); }
.day.today { outline: 2px solid var(--navy); outline-offset: 1px; }
.day small {
  position: absolute; bottom: 2px; right: 4px;
  font-size: .6rem; color: var(--navy);
}
.month-list { list-style: none; padding: 0; margin: 16px 0; }
.month-list a {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.month-list span { margin-left: auto; font-weight: 700; }
.print-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin: 8px 0 16px; }
.print-table th, .print-table td { border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; }
.print-table th { background: var(--navy); color: #fff; }
.year-table .num { text-align: right; white-space: nowrap; }
.kicker { color: var(--terra); font-weight: 700; margin: 0; }
.meta { color: var(--muted); }
.sheet { background: #fff; padding: 8px; }
.print-photos {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.print-photos img { width: 100%; max-height: 240px; object-fit: contain; background: #f4f4f4; }
.print-photos figcaption { font-size: .75rem; }
.sign td { height: 3.2em; }
.install-card { border-top: 3px solid var(--gold); }
.install-grid { display: grid; gap: 16px; }
.install-grid h3 { margin: 0 0 .4rem; font-size: 1rem; color: var(--navy); }
.install-grid ol { margin: .2rem 0 .6rem; padding-left: 1.2rem; }

body.auth-screen {
  padding-bottom: 0;
  background:
    radial-gradient(900px 520px at 12% -10%, #2c537c 0%, transparent 58%),
    radial-gradient(700px 480px at 110% 110%, rgba(194, 78, 40, .45) 0%, transparent 50%),
    #102033;
  color: #fff;
}
body.auth-screen .top { display: none; }
body.auth-screen .main {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  max-width: none;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--paper);
  color: var(--ink);
  border-radius: 28px;
  padding: 32px 26px 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,.28);
  text-align: center;
}
.auth-card .page-title { justify-content: center; }
.auth-card .lead { margin-bottom: 18px; }
.auth-card .btn { margin-top: 8px; }
.auth-foot { margin-top: 16px; font-size: .85rem; color: var(--muted); }

@media print {
  .top, .tabs, .print-actions, .flash { display: none !important; }
  body { padding: 0; background: #fff; }
  .main { max-width: none; padding: 0; }
  .sheet { padding: 0; }
  .card { box-shadow: none; }
  .print-photos { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .split { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
  .visit-card { grid-template-columns: 72px 1fr; }
  .visit-card .cover { width: 72px; min-height: 72px; }
  .filter-bar { grid-template-columns: 1fr; }
  .account-chip { display: none; }
  .brand { font-size: .8rem; }
}
@media (min-width: 768px) {
  .main { max-width: 980px; padding: 22px 28px; }
  .day { width: 52px; height: 52px; }
  .tabs { left: 20px; right: 20px; max-width: 560px; margin: 0 auto; }
  .filter-bar { grid-template-columns: 2fr 1fr 1fr 1fr auto; }
  .filter-bar input[type="search"] { grid-column: auto; }
  .install-grid { grid-template-columns: 1fr 1fr; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (min-width: 900px) and (orientation: landscape) {
  body.has-nav {
    --tab-h: 0px;
    padding-left: calc(96px + env(safe-area-inset-left, 0px));
    padding-bottom: 20px;
  }
  .tabs {
    top: 12px;
    left: calc(10px + env(safe-area-inset-left, 0px));
    right: auto;
    bottom: 12px;
    width: 84px;
    height: auto;
    max-width: none;
    margin: 0;
    padding: 8px 0;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(5, minmax(72px, 1fr));
    border-radius: 24px;
  }
  body.tabs-4 .tabs { grid-template-rows: repeat(4, minmax(72px, 1fr)); }
  .tabs a { margin: 4px 8px; font-size: .7rem; }
}
@media (display-mode: standalone) {
  .top { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
}
