:root {
  color-scheme: light;
  --bg: #f7f8f4;
  --ink: #15211f;
  --muted: #63716d;
  --line: #d9e0dc;
  --panel: #ffffff;
  --green: #1f7a5b;
  --green-dark: #14543f;
  --yellow: #f3b33f;
  --coral: #ef6f5e;
  --blue: #4f83cc;
  --shadow: 0 18px 50px rgba(25, 46, 41, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(31, 122, 91, 0.07), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.8fr);
  gap: 20px;
}

.wheel-panel,
.manage-panel {
  background: var(--panel);
  border: 1px solid rgba(21, 33, 31, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.wheel-panel {
  padding: clamp(18px, 4vw, 32px);
  min-width: 0;
}

.manage-panel {
  padding: 22px;
  min-width: 0;
}

.title-row,
.panel-header,
.panel-tools,
.title-actions,
.form-actions,
.filter-row {
  display: flex;
  align-items: center;
}

.title-row,
.panel-header {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 750;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
}

h2 {
  font-size: 24px;
  line-height: 1.12;
}

.ghost-button,
.primary-button,
.meal-tab,
.filter-chip,
.icon-button,
.spin-button {
  border: 0;
  border-radius: 8px;
}

.ghost-button {
  background: #edf3ef;
  color: var(--green-dark);
  min-height: 40px;
  padding: 0 14px;
  font-weight: 750;
}

.ghost-button.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.title-actions {
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 11px;
  border-radius: 999px;
  background: #edf2f1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.sync-pill.online {
  background: rgba(31, 122, 91, 0.12);
  color: var(--green-dark);
}

.sync-pill.warning {
  background: rgba(239, 111, 94, 0.14);
  color: #a1372d;
}

.primary-button {
  background: var(--green);
  color: #fff;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 800;
}

.meal-tabs {
  margin: 24px 0 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 6px;
  background: #edf2f1;
  border-radius: 8px;
}

.meal-tab {
  min-height: 48px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  font-weight: 850;
}

.meal-tab.active {
  background: #fff;
  color: var(--green-dark);
  box-shadow: 0 7px 18px rgba(20, 84, 63, 0.12);
}

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

.today-strip > div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.today-strip span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.today-strip strong {
  display: block;
  margin-top: 5px;
  min-height: 26px;
  font-size: 20px;
  overflow-wrap: anywhere;
}

.wheel-wrap {
  position: relative;
  width: min(540px, 100%);
  aspect-ratio: 1;
  margin: 26px auto 20px;
  display: grid;
  place-items: center;
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  filter: drop-shadow(0 20px 32px rgba(31, 122, 91, 0.22));
}

.pointer {
  position: absolute;
  top: -5px;
  left: 50%;
  z-index: 3;
  width: 32px;
  height: 44px;
  transform: translateX(-50%);
  background: var(--ink);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}

.spin-button {
  position: absolute;
  z-index: 2;
  width: clamp(104px, 26%, 138px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 8px solid #fff;
  background: var(--green);
  color: #fff;
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(20, 84, 63, 0.28);
}

.spin-button:disabled {
  cursor: not-allowed;
  background: #a8b6b1;
  box-shadow: none;
}

.result-box {
  min-height: 112px;
  padding: 18px;
  border-radius: 8px;
  background: #15211f;
  color: #fff;
}

.result-box span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 14px;
  font-weight: 750;
}

.result-box strong {
  display: block;
  margin-top: 7px;
  font-size: clamp(24px, 5vw, 40px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.result-box p {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.45;
}

.panel-header span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf3ef;
  color: var(--green-dark);
  font-weight: 800;
  white-space: nowrap;
}

.panel-tools {
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.restaurant-form {
  margin-top: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.restaurant-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.restaurant-form input[type="text"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  outline: none;
}

.restaurant-form input[type="text"]:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(31, 122, 91, 0.13);
}

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

.check-pill {
  position: relative;
  display: flex !important;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink) !important;
  background: #fbfcfa;
}

.check-pill input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.check-pill span {
  font-weight: 850;
}

.form-actions {
  gap: 10px;
}

.form-message {
  margin: 10px 0 0;
  min-height: 20px;
  color: var(--coral);
  font-size: 14px;
  font-weight: 750;
}

.filter-row {
  gap: 8px;
  margin: 18px 0 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-chip {
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  background: #edf2f1;
  font-weight: 800;
  white-space: nowrap;
}

.filter-chip.active {
  background: var(--ink);
  color: #fff;
}

.restaurant-list {
  display: grid;
  gap: 10px;
  max-height: 54vh;
  overflow: auto;
  padding-right: 4px;
}

.restaurant-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.restaurant-name {
  min-width: 0;
  font-weight: 900;
  overflow-wrap: anywhere;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 850;
}

.badge.lunch {
  background: rgba(243, 179, 63, 0.22);
  color: #84530c;
}

.badge.dinner {
  background: rgba(79, 131, 204, 0.18);
  color: #275a99;
}

.badge.closed {
  background: #edf2f1;
  color: #7c8a86;
}

.card-actions {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.icon-button {
  width: 36px;
  height: 36px;
  background: #edf3ef;
  color: var(--green-dark);
  font-weight: 900;
}

.icon-button.delete {
  background: rgba(239, 111, 94, 0.13);
  color: #a1372d;
}

.empty-state {
  padding: 24px 16px;
  border: 1px dashed #c7d0cc;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-weight: 750;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(680px, calc(100% - 24px));
    padding: 18px 0;
  }

  .manage-panel {
    order: 2;
  }

  .wheel-panel {
    order: 1;
  }

  .restaurant-list {
    max-height: none;
  }
}

@media (max-width: 700px) {
  body {
    background: #eef4f1;
  }

  .app-shell {
    width: 100%;
    padding: 0 0 max(14px, env(safe-area-inset-bottom));
    gap: 10px;
  }

  .wheel-panel,
  .manage-panel {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .wheel-panel,
  .manage-panel {
    padding: 16px;
  }

  h1 {
    font-size: 44px;
  }

  h2 {
    font-size: 28px;
  }

  .meal-tabs {
    margin: 16px 0 12px;
  }

  .today-strip {
    gap: 8px;
  }

  .today-strip > div {
    padding: 12px;
  }

  .wheel-wrap {
    width: min(390px, 94vw);
    margin: 16px auto 12px;
  }

  .spin-button {
    width: 92px;
    border-width: 7px;
    font-size: 24px;
  }

  .pointer {
    width: 28px;
    height: 38px;
  }

  .result-box {
    min-height: 96px;
    padding: 15px;
  }

  .restaurant-form {
    margin-top: 16px;
  }

  .restaurant-list {
    gap: 8px;
  }
}

@media (max-width: 520px) {
  .title-row,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .title-actions {
    align-items: center;
    width: 100%;
  }

  .title-actions .ghost-button {
    width: auto;
    flex: 1;
  }

  .sync-pill {
    justify-content: center;
    min-width: 86px;
  }

  .today-strip,
  .open-times {
    grid-template-columns: 1fr;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

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

  .card-actions {
    align-items: stretch;
  }

  .icon-button {
    flex: 1;
    width: auto;
  }
}
