:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft JhengHei", system-ui, sans-serif;
  --ink: #17201d;
  --muted: #61706a;
  --line: #d6ddd9;
  --paper: #f7f5ef;
  --panel: #ffffff;
  --green: #1f6b53;
  --green-dark: #164a3b;
  --yellow: #f2c14e;
  --blue: #457b9d;
  --rose: #c75146;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(242, 193, 78, 0.2), transparent 34%),
    linear-gradient(315deg, rgba(69, 123, 157, 0.18), transparent 42%),
    var(--paper);
  color: var(--ink);
}

button,
select,
input,
a {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 18px;
}

.panel,
.list-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(23, 32, 29, 0.08);
}

.controls {
  padding: 24px;
}

.title-row {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1.02;
}

.distance-badge {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 700;
  background: #eef7f1;
}

.control-grid {
  display: grid;
  gap: 14px;
}

.control-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 800;
}

.toggle-field input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
}

select,
input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

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

.custom-wide {
  grid-column: 1 / -1;
}

.recommend-button {
  width: 100%;
  min-height: 54px;
  margin: 22px 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font-weight: 850;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 160ms ease, background 160ms ease;
}

.recommend-button:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

.secondary-button {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.manage-button {
  margin-top: 18px;
}

.nearby-button {
  margin-top: 10px;
}

.status-text {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.status-text.error {
  color: var(--rose);
  font-weight: 700;
}

.mobile-top-button {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(19, 25, 22, 0.42);
  overflow-y: auto;
}

.modal {
  width: min(680px, 100%);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(23, 32, 29, 0.22);
  padding: 18px;
}

.manage-modal {
  width: min(820px, 100%);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 1.4rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.restore-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.manage-section {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

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

.manage-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.manage-heading span {
  color: var(--muted);
  font-weight: 800;
}

.manage-list {
  display: grid;
  gap: 10px;
}

.manage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.manage-item strong,
.manage-item span {
  display: block;
}

.manage-item span {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

.manage-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.compact-button {
  min-height: 46px;
  margin: 0;
}

.restore-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.restore-item strong,
.restore-item span {
  display: block;
}

.restore-item span {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

.restore-item .secondary-button {
  width: auto;
  min-width: 86px;
}

.modal-actions .recommend-button,
.modal-actions .secondary-button {
  width: auto;
  min-width: 120px;
  margin: 0;
}

.note {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.92rem;
}

.result {
  min-height: 520px;
  overflow: hidden;
}

.restaurant-card {
  padding: 26px;
}

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

.pick-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  background: #fff;
}

.pick-card.empty {
  border-style: dashed;
  background: #fafbf8;
}

.pick-card h2 {
  margin: 0 0 10px;
  font-size: clamp(1.3rem, 2vw, 1.7rem);
  line-height: 1.15;
}

.meta,
.reason {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.reason {
  margin-top: 12px;
  color: var(--ink);
}

.stats {
  margin: 16px 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.compact-stats {
  grid-template-columns: repeat(2, 1fr);
}

.stats div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  min-width: 0;
}

.stats dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.stats dd {
  margin: 6px 0 0;
  font-size: 1.12rem;
  font-weight: 850;
}

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

.link-button {
  min-height: 44px;
  padding: 11px 16px;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.link-button.secondary {
  background: #26352f;
}

.reject-button {
  border: 0;
  background: #c75146;
  cursor: pointer;
}

.reject-button:hover {
  background: #a9433b;
}

.link-button[hidden] {
  display: none;
}

.list-panel {
  grid-column: 1 / -1;
  padding: 20px;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.list-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.list-header span {
  color: var(--muted);
  font-weight: 800;
}

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

.candidate {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  min-height: 112px;
  background: #fff;
}

.candidate strong {
  display: block;
  margin-bottom: 7px;
}

.candidate span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.candidate-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.delete-icon-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: 1px solid #e3b7b2;
  border-radius: 50%;
  background: #fff;
  color: #9a312b;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.inline-delete {
  position: static;
  flex: 0 0 auto;
}

.delete-icon-button:hover {
  background: #fae5e3;
}

.preference-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.preference-button.like.active {
  background: #e6f5ec;
  border-color: #6cc38a;
}

.preference-button.dislike.active {
  background: #fae5e3;
  border-color: #d98982;
}

.preference-button.delete {
  color: #9a312b;
  border-color: #e3b7b2;
}

@media (max-width: 860px) {
  body {
    padding-bottom: 86px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 680px);
    padding: 10px 0 20px;
  }

  .title-row {
    display: block;
  }

  .distance-badge {
    display: inline-block;
    margin-top: 14px;
  }

  .result {
    min-height: 0;
  }

  .stats,
  .restaurant-list,
  .custom-form,
  .control-actions {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .recommend-button,
  .modal-actions .secondary-button {
    width: 100%;
  }

  .mobile-top-button {
    position: fixed;
    right: 14px;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 30;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.4rem;
    line-height: 1;
    font-weight: 850;
    box-shadow: 0 12px 28px rgba(23, 32, 29, 0.22);
  }

  .manage-item,
  .restore-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .manage-item-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
