/* のむナビ — スタイル（モバイル優先・375px/320px で横スクロールなし） */

:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7484;
  --muted-2: #6b7484;
  --line: #e7eaf0;
  --blue: #2f6fd0;
  --blue-dark: #275ba8;
  --blue-soft: #eaf2fe;
  --green: #0f7a43;
  --green-dark: #0b6636;
  --green-soft: #e7f6ee;
  --red: #c73a3a;
  --red-dark: #a92e2e;
  --red-soft: #fdecec;
  --yellow-bg: #fdf6dd;
  --yellow-line: #f0d98a;
  --yellow-text: #8a6212;
  --yellow-strong: #b9821a;
  --radius: 16px;
  --radius-sm: 12px;
  --nav-h: 64px;
  --shadow-card: 0 1px 2px rgba(28, 36, 48, 0.04), 0 8px 24px rgba(28, 36, 48, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP",
    "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

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

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1,
h2,
p {
  margin: 0;
}

.icon {
  display: block;
  flex: none;
}

.is-hidden {
  display: none !important;
}

.app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

/* ------------------------------------------------------------- ヘッダー */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 4px;
  padding: 8px 12px 6px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.app-header-titles {
  grid-column: 2;
  min-width: 0;
  text-align: center;
}

#app-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-subtitle {
  margin-top: 1px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header[data-view="settings:profile"] #app-subtitle,
.app-header[data-view="settings:basis"] #app-subtitle {
  display: none;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:active {
  background: #eef1f6;
}

#header-back {
  grid-column: 1;
}

#header-settings {
  grid-column: 3;
}

.icon-btn[hidden] {
  display: flex;
  visibility: hidden;
  pointer-events: none;
}

/* ------------------------------------------------------------- 共通 */

.main {
  padding: 10px 14px calc(var(--nav-h) + 30px + env(safe-area-inset-bottom));
}

.view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  border: 0;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
  filter: brightness(0.97);
}

.btn:disabled {
  cursor: default;
  opacity: 0.42;
}

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

.btn-start {
  background: var(--green);
  color: #fff;
  box-shadow: 0 4px 12px rgba(26, 158, 87, 0.22);
}

.btn-stop {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 12px rgba(224, 85, 85, 0.2);
}

.btn-secondary {
  background: #eef1f6;
  color: #4a5364;
  font-weight: 600;
}

.btn-outline {
  background: #fff;
  border: 1.5px solid var(--line);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  min-height: 56px;
}

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

.btn-danger-outline {
  background: #fff;
  border: 1.5px solid #f0c9c9;
  color: var(--red-dark);
  font-weight: 600;
  min-height: 56px;
  font-size: 15px;
}

.btn-undo {
  background: var(--red-soft);
  border: 1.5px solid #f3c6c6;
  color: #b33535;
  font-weight: 700;
}

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

.btn-water-soft {
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-weight: 700;
  min-height: 56px;
  border: 0;
}

.btn-other {
  justify-content: space-between;
  padding-inline: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: #38404e;
}

.section-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  padding: 6px 8px;
  margin: -6px -8px -6px 0;
}

.empty-note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

/* --------------------------------------------------------------- ホーム */

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
}

.summary-empty {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.summary-main {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.summary-sub {
  font-size: 12.5px;
  color: var(--muted);
}

#first-drink-since {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.metrics {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border: 1.5px solid transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.metrics.is-near {
  background: #fffdf4;
  border-color: var(--yellow-line);
}

.metrics.is-over {
  background: #fff8f7;
  border-color: #f6cccc;
}

.metrics-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.metrics-title {
  font-size: 13px;
  font-weight: 700;
  color: #38404e;
}

.metrics-date {
  font-size: 12px;
  color: var(--muted-2);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.metric {
  min-width: 0;
  text-align: center;
  padding: 2px 2px;
}

.metric + .metric {
  border-left: 1px solid var(--line);
}

.metric-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
  white-space: nowrap;
}

.metric-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  font-weight: 700;
  line-height: 1.15;
}

.metric-value .num {
  font-size: clamp(24px, 7.2vw, 30px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.metric-value .num.is-empty {
  color: var(--muted-2);
}

.metric-value .unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.gauge-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 7px;
}

.gauge-title {
  font-weight: 600;
}

.gauge-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: #eef1f6;
  overflow: visible;
}

.gauge-fill {
  height: 100%;
  min-width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #7cb6f8, var(--blue));
  transition: width 0.3s ease;
}

.gauge-fill.is-over {
  background: linear-gradient(90deg, #f0a35a, var(--red));
}

.gauge-tick {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: #5c6575;
  border-radius: 2px;
  transform: translateX(-1px);
}

.gauge-tick-label {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
}

.gauge-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: var(--muted-2);
}

.limit-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.limit-value strong {
  color: var(--text);
}

.limit-bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #eef1f6;
  overflow: hidden;
}

.limit-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--blue);
  transition: width 0.3s ease;
}

.limit-fill.is-near {
  background: #e8a52b;
}

.limit-fill.is-over {
  background: var(--red);
}

.limit-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(28, 36, 48, 0.18);
}

.warn-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.5;
  font-weight: 600;
}

.warn-banner .icon {
  margin-top: 1px;
}

.warn-near {
  background: var(--yellow-bg);
  border: 1px solid var(--yellow-line);
  color: var(--yellow-text);
}

.warn-over {
  background: #fdeeee;
  border: 1px solid #f3cccc;
  color: #a63a3a;
}

.fav-block {
  padding: 0 2px;
}

.fav-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.fav-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 84px;
  padding: 10px 8px;
  border: 0;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: #eef1f6;
  color: #4a5364;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.06s ease;
}

.fav-tile:active {
  transform: scale(0.97);
}

.tile-amber {
  background: #fdf0cf;
  color: #8a5c07;
}

.tile-sky {
  background: #e4effd;
  color: #2a6bb5;
}

.tile-mint {
  background: #e2f6e6;
  color: #1b6e40;
}

.tile-lilac {
  background: #eee6fb;
  color: #6a45b5;
}

.tile-sand {
  background: #f8efdd;
  color: #7e5a12;
}

.tile-rose {
  background: #fde6ea;
  color: #b53a55;
}

.tile-plain {
  background: #eef1f6;
  color: #4a5364;
}

.tile-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------------------------------------------------- 選択画面 */

.view-sheet {
  padding-top: 2px;
}

.sheet-lead {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: #eaeef4;
  border-radius: 12px;
}

.segment {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.segment.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(28, 36, 48, 0.1);
}

.size-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 4px;
}

.size-head-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
}

.size-drink {
  font-size: 18px;
  font-weight: 700;
}

.size-hint {
  font-size: 13px;
  color: var(--muted);
}

.size-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.size-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.size-row:active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.size-row-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #f6f3e8;
  color: var(--yellow-strong);
  flex: none;
}

.size-row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.size-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.size-row-label {
  font-size: 15px;
  font-weight: 700;
}

.size-row-g {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.size-row-meta {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.size-row-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 44px;
  color: var(--muted);
  flex: none;
}

.row-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  align-self: flex-start;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-over {
  background: #fdecec;
  border: 1px solid #f3cccc;
  color: #a32c2c;
}

.badge-near {
  background: var(--yellow-bg);
  border: 1px solid var(--yellow-line);
  color: var(--yellow-text);
}

.size-today {
  align-self: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.size-today-sep {
  margin: 0 3px;
  color: var(--muted-2);
}

.size-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  padding: 0 2px;
}

/* ---------------------------------------------------------- タイムライン */

.timeline-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 2px;
}

.timeline-title {
  font-size: 16px;
  font-weight: 700;
}

.timeline-date {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 10px 6px;
  margin: -8px -4px -8px 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.timeline-readonly {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #eef2f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.timeline-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 12px 14px;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  font-size: 12.5px;
  color: var(--muted);
}

.timeline-summary strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.timeline {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 4px 0;
}

.tl-item {
  display: grid;
  grid-template-columns: 42px 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 12px 12px;
  border-bottom: 1px solid #f1f3f7;
}

.tl-item:last-child {
  border-bottom: 0;
}

.tl-time {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tl-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #eef1f6;
  color: var(--muted);
}

.tl-icon-start {
  background: var(--green);
  color: #fff;
}

.tl-icon-end {
  background: #4a5364;
  color: #fff;
}

.tl-icon-water {
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.tl-icon-drink {
  background: #fdf3d8;
  color: var(--yellow-strong);
}

.tl-body {
  min-width: 0;
}

.tl-title {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-note {
  font-size: 11.5px;
  color: var(--muted);
}

.tl-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tl-action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--blue-dark);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.tl-action-danger {
  color: var(--muted-2);
}

.tl-action:active {
  background: #eef1f6;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 32px 18px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.empty-icon {
  color: var(--muted-2);
  margin-bottom: 4px;
}

.empty-title {
  font-size: 14px;
  font-weight: 700;
}

.timeline-foot {
  margin-top: 2px;
}

/* ------------------------------------------------------------- 記録の確認 */

.view-confirm {
  gap: 12px;
}

.confirm-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0 0;
}

.confirm-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin-bottom: 2px;
}

.confirm-name {
  font-size: 18px;
  font-weight: 700;
}

.confirm-size {
  font-size: 13px;
  color: var(--muted);
}

.detail-list {
  margin: 0;
  padding: 2px 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.detail-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #f1f3f7;
  font-size: 13.5px;
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row dt {
  color: var(--muted);
}

.detail-row dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.confirm-total {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.confirm-total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.confirm-total-row.is-after {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
}

.confirm-total-row.is-after strong {
  font-size: 22px;
  letter-spacing: -0.01em;
}

.confirm-guide {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.confirm-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.55;
}

.confirm-warning .icon {
  margin-top: 1px;
  flex: none;
}

.confirm-warning.is-over {
  background: #fdeeee;
  border: 1px solid #f3cccc;
  color: #a63a3a;
}

.confirm-warning.is-near {
  background: var(--yellow-bg);
  border: 1px solid var(--yellow-line);
  color: var(--yellow-text);
}

.record-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

/* ----------------------------------------------------------- カレンダー */

.view-calendar {
  gap: 10px;
}

.calendar-card {
  padding: 12px 6px 10px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.calendar-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 4px;
  padding: 0 2px 6px;
}

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.cal-nav:active {
  background: #eef1f6;
}

.calendar-title-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.calendar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.cal-this-month {
  flex: none;
  min-height: 44px;
  margin-block: -6px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: #eef2f8;
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.cal-this-month:active {
  background: #e2e8f2;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
  padding: 0 2px 4px;
}

.cal-weekday {
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 48px;
  padding: 4px 2px;
  border: 1.5px solid transparent;
  border-radius: 9px;
  background: #f5f8fc;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cal-cell.is-blank {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}

.cal-cell.is-today {
  border-color: var(--blue);
}

.cal-cell:active:not(.is-blank) {
  background: #e9eff8;
}

.cal-cell.is-over {
  background: #fdeeee;
}

.cal-cell.is-near {
  background: var(--yellow-bg);
}

.cal-num {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.cal-g {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.cal-cell.is-over .cal-g {
  color: #a63a3a;
}

.cal-cell.is-near .cal-g {
  color: var(--yellow-text);
}

.cal-mark-over {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  color: var(--red);
}

.cal-mark-near {
  position: absolute;
  top: 5px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e8a52b;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 8px 6px 0;
  font-size: 10.5px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-over {
  font-weight: 800;
  color: var(--red);
}

.legend-near {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e8a52b;
}

.calendar-note {
  padding: 0 4px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
}

/* ------------------------------------------------------------- 設定 */

.settings-group {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 6px 0;
  overflow: hidden;
}

.group-title {
  padding: 10px 16px 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px 14px;
  border-bottom: 1px solid #f2f4f8;
}

.settings-row:last-child {
  border-bottom: 0;
}

.settings-row:active {
  background: #f7f9fc;
}

.row-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #f1f4f9;
  color: #56617a;
  flex: none;
}

.row-label {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.row-value {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.row-chevron {
  color: var(--muted-2);
}

.settings-disclaimer {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.7;
  padding: 2px 6px;
}

/* ------------------------------------------------------------ フォーム */

.view-form {
  gap: 12px;
}

.view-form form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 0;
  padding: 0;
}

.field-label {
  font-size: 13px;
  font-weight: 700;
  color: #38404e;
}

.input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}

.input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.select {
  background-image: linear-gradient(45deg, transparent 50%, #8b94a4 50%),
    linear-gradient(135deg, #8b94a4 50%, transparent 50%);
  background-position: calc(100% - 20px) 24px, calc(100% - 14px) 24px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

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

.input-wrap .input {
  flex: 1;
}

.input-unit {
  font-size: 13px;
  color: var(--muted);
  flex: none;
}

.field-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
}

.radio-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.radio-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

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

.radio-chip:has(input:checked) {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.preview-card {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow-card);
}

.preview-label {
  font-size: 11.5px;
  color: var(--muted);
}

.preview-value {
  font-size: 14px;
  color: var(--muted);
}

.preview-value strong {
  font-size: 24px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.preview-note {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.5;
}

.form-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}

.switch-label {
  font-size: 14px;
  font-weight: 600;
  color: #38404e;
}

.switch-row input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: #d9dfe9;
  flex: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.switch-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}

.switch-row input[type="checkbox"]:checked {
  background: var(--green);
}

.switch-row input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}

.auto-value {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.auto-value strong {
  font-size: 18px;
  color: var(--text);
}

.auto-note {
  display: block;
  font-size: 11px;
  color: var(--muted-2);
}

.bac-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------- お酒の管理 */

.list-lead {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.manage-list {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 4px 0;
}

.manage-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #f2f4f8;
}

.manage-row:last-child {
  border-bottom: 0;
}

.star-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #c3cad6;
  cursor: pointer;
  flex: none;
}

.star-btn.is-on {
  color: #e8a52b;
}

.manage-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex: none;
}

.manage-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.manage-name {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manage-meta {
  font-size: 11.5px;
  color: var(--muted);
}

.manage-move {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.move-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: #f1f4f9;
  color: #56617a;
  cursor: pointer;
}

.move-btn:disabled {
  opacity: 0.3;
}

.manage-edit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 40px;
  color: var(--muted-2);
  flex: none;
}

.size-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.size-editor-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.size-editor-row .input {
  min-height: 48px;
  padding: 10px 12px;
}

.size-editor-row .input-sm {
  flex: 1;
}

.size-editor-row .input-wrap.input-sm {
  flex: 0 0 46%;
}

.icon-btn-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: #f4f6fa;
  color: var(--muted);
  flex: none;
  cursor: pointer;
}

.btn-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  min-height: 44px;
  padding: 8px 12px;
  border: 1.5px dashed #cfd6e2;
  border-radius: 10px;
  background: transparent;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.icon-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.icon-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #56617a;
  cursor: pointer;
}

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

.icon-chip.is-active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue-dark);
}

/* --------------------------------------------------------- 静的ページ */

.view-static {
  gap: 12px;
}

.help-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 18px;
  list-style: decimal;
  font-size: 13px;
  line-height: 1.7;
  color: #3b4557;
}

.about-text {
  font-size: 13px;
  line-height: 1.75;
  color: #3b4557;
}

.about-meta {
  font-size: 11.5px;
  color: var(--muted);
}

.edit-time {
  font-size: 12.5px;
  color: var(--muted);
}

/* -------------------------------------------------------------- ナビ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.bottom-nav[hidden] {
  display: none;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.nav-item.is-active {
  color: var(--blue);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
}

.nav-icon-plus {
  width: 40px;
  height: 28px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
}

.nav-item-record {
  color: #6b7484;
}

/* ---------------------------------------------------------- ダイアログ */

.dialog {
  border: 0;
  padding: 0;
  width: calc(100% - 28px);
  max-width: 420px;
  max-height: 88dvh;
  overflow-y: auto;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.28);
}

.dialog button:focus-visible,
.dialog a:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.55);
  outline-offset: 2px;
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog[open] {
  animation: dialog-in 0.18s ease;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.alert-dialog {
  background: var(--yellow-bg);
  border: 1.5px solid var(--yellow-line);
}

.alert-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 18px 18px;
  text-align: center;
}

.alert-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--yellow-strong);
}

.alert-title {
  font-size: 19px;
  font-weight: 800;
  color: var(--yellow-text);
}

.alert-text {
  font-size: 13px;
  line-height: 1.7;
  color: #6f5314;
  font-weight: 600;
}

.alert-current {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
  text-align: left;
}

.alert-current-label {
  font-size: 11.5px;
  color: var(--muted);
}

.alert-current-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--text);
}

.alert-current-value strong {
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.alert-unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.alert-bar {
  height: 8px;
  margin: 8px 0 6px;
  border-radius: 999px;
  background: #eef1f6;
  overflow: hidden;
}

.alert-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f0c24a, #e05555);
  transition: width 0.2s ease;
}

.alert-basis {
  font-size: 11.5px;
  color: var(--muted);
}

.alert-pace {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
}

.alert-body .btn {
  width: 100%;
  min-height: 64px;
}

.alert-body .btn-secondary {
  background: #fff;
  border: 1.5px solid var(--line);
}

.confirm-dialog {
  padding: 20px 18px 16px;
}

.confirm-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.confirm-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 16px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.confirm-actions .btn {
  min-height: 52px;
  font-size: 15px;
}

/* ------------------------------------------------------------- トースト */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 6px;
  width: calc(100% - 32px);
  max-width: 440px;
  padding: 8px 10px 8px 14px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
  animation: toast-in 0.18s ease;
}

.toast[hidden] {
  display: none;
}

.toast-text {
  flex: 1;
  min-width: 0;
  line-height: 1.45;
}

.toast-name,
.toast-msg {
  white-space: nowrap;
}

.toast-action {
  flex: none;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: #b33535;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.toast-action[hidden] {
  display: none;
}

.toast-close {
  flex: none;
  min-width: 36px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* -------------------------------------------------------- 320px 調整 */

@media (max-width: 359px) {
  .main {
    padding-inline: 10px;
  }

  .metrics-grid {
    gap: 2px;
  }

  .metric-value .num {
    font-size: 22px;
  }

  .metric-label {
    font-size: 10px;
  }

  .fav-tile {
    min-height: 88px;
    font-size: 13px;
  }

  .tl-item {
    grid-template-columns: 38px 28px minmax(0, 1fr) auto;
    gap: 6px;
    padding: 10px 8px;
  }

  .tl-action {
    min-width: 36px;
    padding: 0 2px;
  }

  .row-value {
    display: none;
  }

  .alert-current-value strong {
    font-size: 26px;
  }

  .size-row {
    padding: 10px 10px;
    gap: 8px;
  }

  .calendar-card {
    margin-inline: -10px;
    padding-inline: 4px;
  }

  .calendar-grid,
  .calendar-weekdays {
    gap: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
