:root {
  --bg: #f7f0e4;
  --paper: rgba(255, 251, 245, 0.88);
  --ink: #16211e;
  --muted: #56635f;
  --accent: #f45d2d;
  --accent-deep: #b33e14;
  --accent-soft: #ffd8bd;
  --teal: #0e7768;
  --line: rgba(22, 33, 30, 0.12);
  --shadow: 0 20px 50px rgba(109, 68, 31, 0.12);
  --radius: 26px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100dvh;
  background-color: #fff8ee;
  background-image:
    radial-gradient(circle at top left, rgba(244, 93, 45, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(14, 119, 104, 0.14), transparent 30%),
    linear-gradient(180deg, #fff8ee 0%, var(--bg) 42%, #f3eadc 100%);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 16px);
  min-width: min(240px, calc(100vw - 32px));
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(14, 119, 104, 0.96);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 18px 36px rgba(12, 54, 48, 0.22);
  opacity: 0;
  pointer-events: none;
  z-index: 220;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.app-toast[data-tone="warn"] {
  background: rgba(181, 117, 0, 0.96);
}

.app-toast[data-tone="error"] {
  background: rgba(179, 62, 20, 0.96);
}

img,
video {
  display: block;
  max-width: 100%;
}

button,
input,
textarea {
  font: inherit;
}

.layout {
  width: min(1120px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.hero,
.panel {
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 24px;
  padding: 28px;
  margin-bottom: 22px;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -46% auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 93, 45, 0.2), transparent 70%);
  pointer-events: none;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 10px;
  color: var(--accent-deep);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1,
.panel h2,
.history-heading h3 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
}

.hero h1 {
  max-width: 12ch;
  font-size: clamp(2.2rem, 5vw, 4.5rem);
  line-height: 0.96;
}

.hero-copy,
.hint,
.result-meta,
.history-meta,
.history-notes {
  color: var(--muted);
}

.hero-copy {
  max-width: 48ch;
  margin: 14px 0 0;
  line-height: 1.6;
}

.hero-copy-compact {
  display: none;
}

.hero-side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.hint {
  margin: 0;
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 22px;
}

.workflow-panel {
  transition:
    padding 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    opacity 180ms ease;
}

.result-panel {
  scroll-margin-top: 16px;
}

.result-panel:focus {
  outline: none;
}

.panel {
  padding: 24px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.status-banner,
.history-count {
  border-radius: 999px;
  white-space: nowrap;
}

.status-banner {
  padding: 10px 14px;
  background: rgba(22, 33, 30, 0.06);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
}

.status-banner[data-tone="ok"] {
  background: rgba(14, 119, 104, 0.12);
  color: #085549;
}

.status-banner[data-tone="warn"] {
  background: rgba(255, 191, 0, 0.18);
  color: #755600;
}

.status-banner[data-tone="error"] {
  background: rgba(179, 62, 20, 0.12);
  color: #8d2c0a;
}

.status-banner[data-tone="loading"] {
  background: rgba(244, 93, 45, 0.14);
  color: var(--accent-deep);
}

.camera-stage {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(244, 93, 45, 0.08), rgba(14, 119, 104, 0.08)),
    #faf6ef;
}

.camera-stage video,
.camera-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 26px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.result-panel > .status-banner {
  margin-bottom: 14px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 0;
}

.camera-stage:not([hidden]) ~ .action-row {
  margin-top: 16px;
}

.capture-sheet-bar {
  display: none;
}

.capture-sheet-kicker {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-deep);
  text-transform: uppercase;
}

.capture-sheet-title {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
}

.capture-sheet-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.capture-sheet-chip,
.capture-sheet-toggle {
  appearance: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}

.capture-sheet-chip {
  padding: 10px 14px;
  background: rgba(14, 119, 104, 0.1);
  color: var(--teal);
}

.capture-sheet-chip--primary {
  background: linear-gradient(135deg, var(--accent), #ff8c4c);
  color: #fff;
}

.capture-sheet-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(22, 33, 30, 0.06);
  color: var(--ink);
}

.capture-sheet-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 180ms ease;
}

.capture-sheet-chip:disabled,
.capture-sheet-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.capture-sheet-body {
  display: contents;
}

.text-input-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.text-input-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.text-input-divider::before,
.text-input-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.food-text-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  resize: none;
  line-height: 1.55;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.food-text-input:focus {
  outline: none;
  border-color: rgba(14, 119, 104, 0.38);
  box-shadow: 0 0 0 3px rgba(14, 119, 104, 0.08);
}

.food-text-input::placeholder {
  color: var(--muted);
}

.text-analyze-button {
  align-self: flex-end;
}

.history-card.no-image {
  grid-template-columns: 1fr;
}

.primary-button,
.secondary-button,
.ghost-button,
.file-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.primary-button,
.secondary-button,
.ghost-button,
.file-button {
  padding: 12px 18px;
  font-weight: 700;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #ff8c4c);
  color: white;
}

.secondary-button {
  background: rgba(14, 119, 104, 0.1);
  color: var(--teal);
}

.ghost-button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 216, 189, 0.58);
  color: var(--accent-deep);
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.file-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.result-card {
  display: grid;
  gap: 16px;
  min-height: 100%;
  padding: 22px;
  border-radius: 24px;
  background:
    linear-gradient(160deg, rgba(255, 216, 189, 0.58), rgba(255, 251, 245, 0.92)),
    white;
  border: 1px solid rgba(244, 93, 45, 0.18);
}

.result-panel .result-card {
  transition:
    min-height 180ms ease,
    padding 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.result-card.empty {
  opacity: 0.84;
}

.result-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid rgba(22, 33, 30, 0.08);
}

.result-headline {
  margin: 0;
  font-size: 1.42rem;
  font-weight: 800;
}

.result-meta,
.result-block {
  margin: 0;
  line-height: 1.6;
}

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

.metric {
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(244, 93, 45, 0.12);
}

.metric-label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric strong {
  font-size: 1.3rem;
}

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

.macro {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(14, 119, 104, 0.12);
}

.macro-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.macro strong {
  font-size: 1.05rem;
}

.muted {
  color: var(--muted);
}

.result-items {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(22, 33, 30, 0.08);
  border-radius: 18px;
}

.refinement-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.refinement-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  resize: none;
  line-height: 1.55;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.refinement-input:focus {
  outline: none;
  border-color: rgba(14, 119, 104, 0.38);
  box-shadow: 0 0 0 3px rgba(14, 119, 104, 0.08);
}

.refinement-input::placeholder {
  color: var(--muted);
}

.refinement-button {
  align-self: flex-end;
}

.calendar-panel {
  margin-top: 22px;
}

.calendar-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.calendar-nav-arrow {
  appearance: none;
  border: none;
  background: rgba(22, 33, 30, 0.07);
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  padding: 5px 13px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  transition: background 160ms ease, transform 160ms ease;
}

.calendar-nav-arrow:hover {
  background: rgba(22, 33, 30, 0.13);
  transform: translateY(-1px);
}

.calendar-month-wrapper {
  position: relative;
}

.calendar-month-label {
  appearance: none;
  border: none;
  background: transparent;
  min-width: 8ch;
  text-align: center;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background 160ms ease;
}

.calendar-month-label:hover {
  background: rgba(22, 33, 30, 0.07);
}

.calendar-month-picker {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 148px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 6px;
}

.calendar-month-option {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: none;
  background: transparent;
  text-align: center;
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  transition: background 160ms ease;
}

.calendar-month-option:hover {
  background: rgba(22, 33, 30, 0.06);
}

.calendar-month-option.active {
  background: rgba(244, 93, 45, 0.1);
  color: var(--accent-deep);
  font-weight: 700;
}

.calendar-month-picker-empty {
  margin: 0;
  padding: 12px 14px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.calendar-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.calendar-summary-card {
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(22, 33, 30, 0.08);
}

.calendar-summary-label {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.calendar-summary-card strong {
  font-size: 1.22rem;
}

.calendar-macro-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: -8px;
  margin-bottom: 18px;
}

.calendar-macro-item strong {
  color: var(--text);
  font-size: 0.82rem;
}

.calendar-macro-sep {
  color: var(--line);
}

.calendar-day-macros {
  margin-top: -12px;
  margin-bottom: 14px;
}

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

.calendar-weekdays {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.calendar-day {
  display: grid;
  align-content: space-between;
  aspect-ratio: 1 / 1;
  min-height: 0;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid rgba(22, 33, 30, 0.08);
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  text-align: left;
}

button.calendar-day {
  appearance: none;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

button.calendar-day:hover {
  transform: translateY(-1px);
  border-color: rgba(244, 93, 45, 0.22);
}

.calendar-day-empty {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.calendar-day.has-entry {
  background: linear-gradient(180deg, rgba(255, 216, 189, 0.32), rgba(255, 255, 255, 0.82));
  border-color: rgba(244, 93, 45, 0.18);
}

.calendar-day.entry-low {
  background: linear-gradient(180deg, rgba(255, 231, 208, 0.42), rgba(255, 255, 255, 0.84));
}

.calendar-day.entry-medium {
  background: linear-gradient(180deg, rgba(255, 210, 179, 0.48), rgba(255, 255, 255, 0.86));
}

.calendar-day.entry-high {
  background: linear-gradient(180deg, rgba(244, 93, 45, 0.18), rgba(255, 247, 241, 0.96));
  border-color: rgba(244, 93, 45, 0.28);
}

.calendar-day.selected {
  background: linear-gradient(180deg, rgba(244, 93, 45, 0.14), rgba(255, 255, 255, 0.9));
  border-color: rgba(244, 93, 45, 0.38);
  box-shadow: 0 10px 24px rgba(244, 93, 45, 0.08);
}

.calendar-day.today .calendar-day-number {
  color: var(--accent-deep);
}

.calendar-day-number {
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1;
}

.calendar-day-summary {
  justify-self: end;
  align-self: end;
}

.calendar-day-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6em;
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(244, 93, 45, 0.14);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
}

.calendar-day-panel {
  margin-top: 22px;
}

.calendar-day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.calendar-day-header h2 {
  margin: 0;
}

.calendar-day-total {
  font-size: 1rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.selected-date-list {
  display: grid;
  gap: 14px;
}

.calendar-entry-card {
  animation-delay: var(--delay, 0ms);
}

.calendar-error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(179, 62, 20, 0.12);
}

.history-card {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(22, 33, 30, 0.08);
  animation: rise-in 420ms ease both;
  animation-delay: var(--delay, 0ms);
}

.history-image {
  aspect-ratio: 1;
  border-radius: 18px;
  object-fit: cover;
}

.history-content {
  min-width: 0;
}

.history-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-heading h3 {
  font-size: 1.14rem;
}

.history-meta,
.history-notes,
.empty-history {
  margin: 6px 0 0;
  line-height: 1.55;
}

body.workflow-focused .workflow-grid {
  grid-template-columns: minmax(300px, 0.84fr) minmax(380px, 1.16fr);
  align-items: start;
}

body.workflow-focused .capture-panel {
  padding: 18px;
}

body.workflow-focused .capture-panel .camera-stage {
  aspect-ratio: 16 / 10;
  border-radius: 18px;
}

body.workflow-focused .result-panel {
  padding: 28px;
  border-color: rgba(244, 93, 45, 0.18);
  box-shadow: 0 28px 58px rgba(95, 55, 29, 0.14);
}

body.workflow-focused .result-panel .result-card {
  min-height: 100%;
  padding: 24px;
  box-shadow: 0 16px 40px rgba(244, 93, 45, 0.08);
}

body.has-result .workflow-grid {
  grid-template-columns: minmax(280px, 0.76fr) minmax(420px, 1.24fr);
}

body.has-result .capture-panel {
  opacity: 0.96;
}

body.has-result .capture-panel .camera-stage {
  aspect-ratio: 16 / 9;
}

body.has-result .result-panel .result-card {
  min-height: 520px;
}

body.standalone-mode .layout {
  padding-top: max(12px, env(safe-area-inset-top));
}

body.standalone-mode .hero {
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

body.standalone-mode .hero::after {
  width: 180px;
  height: 180px;
  inset: auto -6% -50% auto;
}

body.standalone-mode .hero h1 {
  max-width: none;
  font-size: clamp(1.45rem, 5vw, 2rem);
  line-height: 1.05;
}

body.standalone-mode .hero-copy-full,
body.standalone-mode .hero-side .hint {
  display: none;
}

body.standalone-mode .hero-copy-compact {
  display: block;
  margin-top: 8px;
}

.pwa-user-bar {
  display: none;
}

body.standalone-mode .pwa-user-bar {
  display: flex;
  justify-content: flex-end;
  padding: 4px 4px 8px;
}

body.standalone-mode .hero-side .user-chip {
  display: none;
}

body.standalone-mode .hero-side {
  flex-direction: row;
  justify-content: flex-start;
}

body.standalone-mode .grid {
  gap: 16px;
}

.history-date-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 4px 0 2px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(14, 119, 104, 0.08);
  color: var(--teal);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease;
}

.history-date-badge input[type="datetime-local"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.history-date-badge:hover {
  background: rgba(14, 119, 104, 0.15);
}

.history-date-badge.busy {
  opacity: 0.55;
  pointer-events: none;
}

.history-feedback-toggle {
  appearance: none;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(14, 119, 104, 0.2);
  background: rgba(14, 119, 104, 0.06);
  color: var(--teal);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.history-feedback-toggle:hover {
  transform: translateY(-1px);
  background: rgba(14, 119, 104, 0.1);
}

.history-feedback-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.history-macros {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.history-macros span {
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  padding: 2px 6px;
}

.history-delete-button {
  appearance: none;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(179, 62, 20, 0.18);
  background: rgba(179, 62, 20, 0.08);
  color: var(--accent-deep);
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.history-delete-button:hover {
  transform: translateY(-1px);
  background: rgba(179, 62, 20, 0.12);
}

.history-delete-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .hero,
  .grid {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    max-width: 14ch;
  }

  body.workflow-focused .workflow-grid,
  body.has-result .workflow-grid {
    grid-template-columns: 1fr;
  }

  body.workflow-focused .result-panel {
    padding: 24px;
  }

  .calendar-day-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .layout {
    width: min(100vw - 18px, 100%);
    padding: 18px 0 24px;
  }

  .hero,
  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .panel-header,
  .history-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .history-card {
    grid-template-columns: 1fr;
  }



  .calendar-weekdays,
  .calendar-grid {
    gap: 4px;
  }

  .calendar-day {
    padding: 5px;
    border-radius: 12px;
  }

  .calendar-day-value {
    min-width: 0;
    padding: 3px 4px;
    font-size: 0.62rem;
  }

  .calendar-day-number {
    font-size: 0.76rem;
  }

  .calendar-weekdays {
    margin-bottom: 8px;
    font-size: 0.72rem;
  }

  body.workflow-focused .workflow-grid {
    gap: 16px;
  }

  body.workflow-focused .capture-panel {
    padding: 16px;
  }

  body.workflow-focused .capture-panel .camera-stage {
    aspect-ratio: 16 / 9;
  }

  body.workflow-focused .capture-panel .action-row {
    gap: 10px;
  }

  body.has-result .result-panel .result-card {
    min-height: auto;
  }

  body.standalone-mode .hero {
    padding: 14px 16px;
  }

  body.tab-capture #workflowGrid,
  body.standalone-mode.tab-capture #workflowGrid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding-bottom: 12px;
  }

  body.tab-capture #resultPanel,
  body.standalone-mode.tab-capture #resultPanel {
    order: 1;
  }

  body.tab-capture #capturePanel,
  body.standalone-mode.tab-capture #capturePanel {
    order: 2;
    position: sticky;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    z-index: 90;
    padding: 14px 14px 12px;
    background: rgba(255, 251, 245, 0.96);
    backdrop-filter: blur(18px) saturate(1.35);
    -webkit-backdrop-filter: blur(18px) saturate(1.35);
    box-shadow:
      0 24px 56px rgba(95, 55, 29, 0.22),
      0 8px 18px rgba(95, 55, 29, 0.1);
  }

  .capture-sheet-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }

  .capture-sheet-copy {
    min-width: 0;
    flex: 1;
  }

  .capture-sheet-title {
    line-height: 1.2;
  }

  .capture-sheet-actions {
    flex-shrink: 0;
  }

  .capture-sheet-chip,
  .capture-sheet-toggle {
    min-height: 44px;
  }

  body.capture-sheet-expanded .capture-sheet-chip {
    display: none;
  }

  .capture-sheet-body {
    display: grid;
    gap: 0;
    margin-top: 14px;
    overflow: hidden;
    transform-origin: bottom center;
    transition:
      max-height 220ms ease,
      opacity 180ms ease,
      transform 180ms ease,
      margin-top 180ms ease;
  }

  body.capture-sheet-expanded .capture-sheet-body {
    max-height: 720px;
    opacity: 1;
    transform: translateY(0);
  }

  body:not(.capture-sheet-expanded) .capture-sheet-body {
    max-height: 0;
    opacity: 0;
    transform: translateY(10px);
    margin-top: 0;
    pointer-events: none;
  }

  body.capture-sheet-expanded .capture-sheet-toggle svg {
    transform: rotate(180deg);
  }

  body.capture-sheet-expanded.tab-capture #capturePanel,
  body.capture-sheet-expanded.standalone-mode.tab-capture #capturePanel {
    padding-bottom: 16px;
  }

  body.capture-sheet-expanded.tab-capture #workflowGrid,
  body.capture-sheet-expanded.standalone-mode.tab-capture #workflowGrid {
    padding-bottom: 24px;
  }

  body.tab-capture .capture-panel .action-row,
  body.standalone-mode.tab-capture .capture-panel .action-row {
    margin-top: 0;
  }

  body.tab-capture .capture-panel .action-row > *,
  body.standalone-mode.tab-capture .capture-panel .action-row > * {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
  }

  body.tab-capture .capture-panel .text-analyze-button,
  body.standalone-mode.tab-capture .capture-panel .text-analyze-button {
    align-self: stretch;
  }

  body.tab-capture .capture-panel .file-button,
  body.standalone-mode.tab-capture .capture-panel .file-button {
    justify-content: center;
  }
}

/* ── User chip ─────────────────────────────────────────────── */

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  background: rgba(14, 119, 104, 0.07);
  border: 1px solid rgba(14, 119, 104, 0.14);
  border-radius: 100px;
  width: fit-content;
  max-width: 100%;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-name {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-link {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  padding: 2px 7px;
  border-radius: 8px;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

.logout-link:hover {
  background: rgba(244, 93, 45, 0.1);
  color: var(--accent);
}

/* ── Tab bar ──────────────────────────────────────────────── */

.tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 251, 245, 0.94);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-top: 1px solid var(--line);
  z-index: 100;
  align-items: stretch;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  width: 100%;
  min-height: 64px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 12px 0 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.14s;
}

.tab-item svg {
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.tab-item span {
  pointer-events: none;
}

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

.tab-fab-wrap {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0 0 8px;
}

.tab-fab {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), #ff8c4c);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(244, 93, 45, 0.38), 0 1px 4px rgba(0,0,0,0.1);
  position: relative;
  top: -10px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.14s, box-shadow 0.14s;
}

.tab-fab:active {
  transform: translateY(2px) scale(0.96);
  box-shadow: 0 2px 8px rgba(244, 93, 45, 0.28);
}

.tab-fab svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
  pointer-events: none;
}

/* section panels */
.tab-panel {
  display: none;
}

.health-panel {
  min-height: 260px;
}

.about-panel {
  min-height: clamp(460px, calc(100dvh - 200px), 720px);
}

.about-visual {
  position: relative;
  flex: 1 1 auto;
  min-height: 240px;
  overflow: hidden;
  border-radius: 30px;
  pointer-events: none;
}

.about-visual-halo {
  position: absolute;
  border-radius: 50%;
  filter: blur(10px);
  opacity: 0.9;
}

.about-visual-halo--warm {
  width: 220px;
  height: 220px;
  top: 10px;
  left: -24px;
  background: radial-gradient(circle, rgba(244, 93, 45, 0.22), rgba(244, 93, 45, 0.02) 72%);
}

.about-visual-halo--cool {
  width: 200px;
  height: 200px;
  right: -12px;
  top: 34px;
  background: radial-gradient(circle, rgba(14, 119, 104, 0.2), rgba(14, 119, 104, 0.02) 70%);
}

.about-visual-plate {
  position: absolute;
  left: 50%;
  top: 46%;
  width: min(62vw, 220px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.98), rgba(255, 250, 245, 0.94) 54%, rgba(255, 225, 198, 0.74) 78%, rgba(255, 209, 177, 0.42) 100%);
  border: 1px solid rgba(244, 93, 45, 0.16);
  box-shadow:
    0 24px 50px rgba(109, 68, 31, 0.12),
    inset 0 2px 10px rgba(255, 255, 255, 0.75);
}

.about-visual-ring,
.about-visual-carrot,
.about-visual-carrot-top,
.about-visual-spark {
  position: absolute;
}

.about-visual-ring {
  inset: 18px;
  border-radius: 50%;
  border: 1px solid rgba(22, 33, 30, 0.1);
}

.about-visual-carrot {
  border-radius: 18px 18px 28px 28px / 14px 14px 84px 84px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 34%),
    linear-gradient(180deg, rgba(255, 183, 110, 0.98), rgba(248, 118, 53, 0.98) 58%, rgba(211, 74, 26, 0.98) 100%);
  box-shadow:
    0 14px 24px rgba(179, 62, 20, 0.16),
    inset -5px -10px 14px rgba(181, 66, 27, 0.22);
}

.about-visual-carrot-top::before,
.about-visual-carrot-top::after {
  content: "";
  position: absolute;
  top: 0;
  width: 18px;
  height: 32px;
  border-radius: 100% 0 100% 0;
  background: linear-gradient(135deg, rgba(135, 214, 165, 0.98), rgba(24, 134, 93, 0.98));
  box-shadow: 0 8px 16px rgba(21, 104, 74, 0.16);
}

.about-visual-carrot-top::before {
  left: 0;
  transform: rotate(-24deg);
}

.about-visual-carrot-top::after {
  right: 0;
  transform: scaleX(-1) rotate(-18deg);
}

.about-visual-carrot-top {
  z-index: 4;
  width: 26px;
  height: 30px;
}

.about-visual-carrot--one {
  z-index: 3;
  width: 46px;
  height: 96px;
  left: 58px;
  top: 54px;
  transform: rotate(-16deg);
}

.about-visual-carrot-top--one {
  left: 71px;
  top: 36px;
  transform: rotate(-14deg);
}

.about-visual-carrot--two {
  z-index: 2;
  width: 40px;
  height: 84px;
  left: 102px;
  top: 70px;
  transform: rotate(10deg);
}

.about-visual-carrot-top--two {
  left: 112px;
  top: 52px;
  transform: rotate(8deg) scale(0.92);
}

.about-visual-carrot--three {
  z-index: 1;
  width: 34px;
  height: 72px;
  left: 136px;
  top: 92px;
  transform: rotate(26deg);
}

.about-visual-carrot-top--three {
  left: 142px;
  top: 76px;
  transform: rotate(24deg) scale(0.82);
}

.about-visual-spark {
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 228, 186, 0.96), rgba(255, 203, 140, 0.54) 70%, rgba(255, 203, 140, 0) 100%);
}

.about-visual-spark--one {
  width: 16px;
  height: 16px;
  left: 52px;
  top: 138px;
}

.about-visual-spark--two {
  width: 12px;
  height: 12px;
  left: 150px;
  top: 62px;
}

.about-visual-mark {
  position: absolute;
  right: 8px;
  bottom: -6px;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(4.4rem, 19vw, 7rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.08em;
  color: rgba(179, 62, 20, 0.1);
}

.about-account-panel {
  margin-top: auto;
}

.placeholder-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 12px;
  text-align: center;
}

.placeholder-icon {
  width: 48px;
  height: 48px;
  color: var(--muted);
  opacity: 0.5;
}

.placeholder-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.placeholder-sub {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0;
}

.about-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 0 18px;
}

.about-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 1.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.about-user-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.about-section-label {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-deep);
  text-transform: uppercase;
}

.about-username {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}

.about-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.about-menu li {
  border-bottom: 1px solid var(--line);
}

.about-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: opacity 0.12s;
}

.about-menu-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.about-menu-item--danger {
  color: #d93f3f;
}

.about-footer {
  margin: 96px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* show tab bar + section switching on mobile & standalone */
@media (max-width: 640px) {
  .hero,
  .pwa-user-bar,
  body.standalone-mode .hero,
  body.standalone-mode .pwa-user-bar {
    display: none;
  }

  .app-toast {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }

  .tab-bar { display: flex; }

  .layout {
    padding-bottom: calc(50px + max(16px, env(safe-area-inset-bottom, 0px)));
  }

  body.tab-capture .calendar-panel,
  body.tab-capture #healthPanel,
  body.tab-capture #aboutPanel { display: none; }

  body.tab-calendar #workflowGrid,
  body.tab-calendar #healthPanel,
  body.tab-calendar #aboutPanel { display: none; }
  body.tab-calendar .calendar-panel {
    display: block;
    margin-top: 0;
    margin-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }

  body.tab-health #workflowGrid,
  body.tab-health .calendar-panel,
  body.tab-health #aboutPanel { display: none; }
  body.tab-health #healthPanel { display: block; }

  body.tab-about #workflowGrid,
  body.tab-about .calendar-panel,
  body.tab-about #healthPanel { display: none; }
  body.tab-about #aboutPanel {
    --about-tab-clearance: calc(92px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: calc(100dvh - 170px - var(--about-tab-clearance));
    padding-bottom: var(--about-tab-clearance);
  }

  body.tab-about .about-visual {
    min-height: 260px;
  }
}

body.standalone-mode .tab-bar { display: flex; }

body.standalone-mode .layout {
  padding-bottom: calc(50px + max(16px, env(safe-area-inset-bottom)));
}

body.standalone-mode.tab-capture .calendar-panel,
body.standalone-mode.tab-capture #healthPanel,
body.standalone-mode.tab-capture #aboutPanel { display: none; }

body.standalone-mode.tab-calendar #workflowGrid,
body.standalone-mode.tab-calendar #healthPanel,
body.standalone-mode.tab-calendar #aboutPanel { display: none; }
body.standalone-mode.tab-calendar .calendar-panel {
  display: block;
  margin-top: 0;
  margin-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

body.standalone-mode.tab-health #workflowGrid,
body.standalone-mode.tab-health .calendar-panel,
body.standalone-mode.tab-health #aboutPanel { display: none; }
body.standalone-mode.tab-health #healthPanel { display: block; }

body.standalone-mode.tab-about #workflowGrid,
body.standalone-mode.tab-about .calendar-panel,
body.standalone-mode.tab-about #healthPanel { display: none; }
body.standalone-mode.tab-about #aboutPanel {
  --about-tab-clearance: calc(92px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: calc(100dvh - 154px - var(--about-tab-clearance));
  padding-bottom: var(--about-tab-clearance);
}

body.standalone-mode.tab-about .about-visual {
  min-height: 280px;
}
