:root {
  color-scheme: light;
  --bg: #f6f1e7;
  --paper: rgba(255, 251, 245, 0.92);
  --panel: rgba(255, 255, 255, 0.84);
  --border: rgba(36, 39, 46, 0.14);
  --text: #21242b;
  --muted: #5f6673;
  --accent: #db5f39;
  --accent-strong: #c24d28;
  --accent-soft: rgba(219, 95, 57, 0.14);
  --teal: #2a8f8b;
  --gold: #d39b2f;
  --shadow: 0 22px 50px rgba(40, 33, 26, 0.12);
  --radius: 8px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(42, 143, 139, 0.18), transparent 28%),
    radial-gradient(circle at bottom left, rgba(211, 155, 47, 0.18), transparent 22%),
    var(--bg);
  color: var(--text);
}

body {
  min-width: 320px;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

canvas {
  display: block;
}

.app-shell {
  min-height: 100vh;
}

.hero {
  position: relative;
  min-height: 280px;
  padding: 28px clamp(18px, 4vw, 40px);
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(32, 36, 43, 0.24), rgba(32, 36, 43, 0.52)),
    #3d4038;
}

.hero__backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(18, 20, 24, 0.08), rgba(18, 20, 24, 0.3)),
    url("./assets/food-hero.png") center/cover no-repeat;
  transform: scale(1.02);
}

.hero__content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 420px);
  align-items: end;
  gap: 24px;
  min-height: 224px;
}

.hero__eyebrow {
  margin: 0 0 12px;
  color: rgba(255, 249, 241, 0.88);
  font-size: 0.94rem;
}

.hero h1 {
  margin: 0;
  max-width: 10ch;
  color: #fff8f0;
  font-size: clamp(2.1rem, 4vw, 3.9rem);
  line-height: 1;
  letter-spacing: 0;
}

.hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero__signature {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin: 14px 0 0;
  padding: 0 14px;
  border: 1px solid rgba(255, 248, 240, 0.22);
  border-radius: 999px;
  background: rgba(255, 248, 240, 0.12);
  color: #fff8f0;
  font-size: 0.96rem;
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
}

.stat-pill,
.meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 248, 240, 0.18);
  border-radius: 999px;
  background: rgba(255, 248, 240, 0.14);
  color: #fff8f0;
  white-space: nowrap;
}

.hero__result {
  display: grid;
  gap: 10px;
  padding: 18px 20px;
  background: rgba(255, 248, 240, 0.16);
  border: 1px solid rgba(255, 248, 240, 0.2);
  backdrop-filter: blur(16px);
  border-radius: var(--radius);
  color: #fffdf8;
}

.result-label {
  font-size: 0.9rem;
  color: rgba(255, 248, 240, 0.86);
}

.hero__result strong {
  font-size: clamp(1.5rem, 2.6vw, 2.3rem);
  line-height: 1.1;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(340px, 520px);
  gap: 26px;
  padding: 22px clamp(16px, 4vw, 40px) 32px;
}

.wheel-stage,
.control-stage {
  min-width: 0;
}

.wheel-panel,
.control-block {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.wheel-panel {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 18px;
  padding: 20px;
}

.wheel-frame {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  width: min(100%, 720px);
  margin: 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.05) 64%),
    linear-gradient(135deg, rgba(219, 95, 57, 0.08), rgba(42, 143, 139, 0.12));
}

.wheel-pointer {
  position: absolute;
  top: -2px;
  left: 50%;
  width: 30px;
  height: 34px;
  margin-left: -15px;
  z-index: 3;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  background: linear-gradient(180deg, #ffe4b8, #db5f39);
  filter: drop-shadow(0 12px 18px rgba(28, 23, 17, 0.22));
}

#wheel {
  width: 100%;
  height: 100%;
  max-width: 640px;
  max-height: 640px;
  transform-origin: center center;
}

.wheel-center-button {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 0 14px;
  width: clamp(92px, 18%, 116px);
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #24272e, #181b21);
  color: #fff8f0;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
  box-shadow: 0 12px 34px rgba(30, 25, 20, 0.34);
}

.wheel-center-button:disabled {
  opacity: 0.66;
  cursor: wait;
}

.wheel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.wheel-actions--tools {
  align-items: center;
}

#sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  overflow-wrap: anywhere;
}

#sync-status[data-tone="ok"] {
  color: #166764;
}

#sync-status[data-tone="warn"] {
  color: #9e3f26;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
}

.button:disabled,
.icon-button:disabled {
  opacity: 0.66;
  cursor: not-allowed;
}

.button--primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  border-color: rgba(194, 77, 40, 0.42);
  color: #fffaf4;
}

.button--secondary {
  background: rgba(42, 143, 139, 0.1);
  border-color: rgba(42, 143, 139, 0.24);
}

.button--ghost {
  background: rgba(255, 255, 255, 0.55);
}

.status-line {
  min-height: 24px;
  color: var(--muted);
}

.control-stage {
  display: grid;
  gap: 18px;
  align-content: start;
}

.control-block {
  padding: 18px;
}

.control-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.control-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.mini-note {
  color: var(--muted);
  font-size: 0.92rem;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.switch input {
  margin: 0;
  accent-color: var(--accent);
}

.filter-grid {
  display: grid;
  gap: 16px;
}

.filter-group {
  display: grid;
  gap: 8px;
}

.filter-title {
  color: var(--muted);
  font-size: 0.92rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 8px;
}

.segmented button {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

.segmented button.is-active {
  background: var(--accent-soft);
  border-color: rgba(219, 95, 57, 0.36);
  color: var(--accent-strong);
}

select,
input[type="text"] {
  min-height: 42px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

.food-list,
.history-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.food-item,
.history-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(36, 39, 46, 0.08);
  border-radius: var(--radius);
  background: var(--panel);
}

.food-item.is-dim {
  opacity: 0.58;
}

.food-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.food-toggle {
  width: 18px;
  height: 18px;
  margin: 0;
}

.food-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.food-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(36, 39, 46, 0.07);
  color: var(--muted);
  white-space: nowrap;
}

.tag--budget {
  background: rgba(211, 155, 47, 0.12);
  color: #8a6519;
}

.tag--spice {
  background: rgba(219, 95, 57, 0.12);
  color: #9e3f26;
}

.tag--pace {
  background: rgba(42, 143, 139, 0.12);
  color: #166764;
}

.weight-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.weight-box button,
.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}

.weight-value {
  min-width: 32px;
  text-align: center;
  font-weight: 700;
}

.food-row-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.food-row-actions label {
  color: var(--muted);
  font-size: 0.92rem;
}

.add-form {
  display: grid;
  gap: 14px;
}

.add-form label {
  display: grid;
  gap: 8px;
}

.add-form span {
  color: var(--muted);
  font-size: 0.92rem;
}

.add-form .button {
  justify-self: start;
}

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

.history-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.history-item strong {
  display: block;
  margin-bottom: 6px;
}

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

.history-rank {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(219, 95, 57, 0.12);
  color: var(--accent-strong);
  font-weight: 700;
}

.empty-state {
  padding: 14px;
  border: 1px dashed rgba(36, 39, 46, 0.16);
  border-radius: var(--radius);
  color: var(--muted);
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .wheel-panel {
    position: static;
  }

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

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

@media (max-width: 720px) {
  .hero {
    min-height: 260px;
    padding-inline: 16px;
  }

  .workspace {
    padding-inline: 12px;
  }

  .control-block,
  .wheel-panel {
    padding: 14px;
  }

  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .control-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .wheel-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .food-main {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .food-main .weight-box {
    grid-column: 2;
    justify-self: start;
  }

  .food-row-actions {
    flex-direction: column;
    align-items: flex-start;
  }
}
