:root {
  --brand: #ff7a1a;
  --brand-dark: #e05f00;
  --brand-light: #fff1e6;
  --teal: #0e7c7b;
  --teal-dark: #0a5f5e;
  --ink: #263238;
  --muted: #6b7a85;
  --bg: #f6f7f9;
  --card: #ffffff;
  --line: #e4e8ec;
  --danger: #d93025;
  --ok: #188038;
  --danger-bg: #fdecea;
  --danger-line: #f5c6c2;
  --banner-bg: #fef7e0;
  --banner-line: #f2d98a;
  --banner-ink: #7a5b00;
  --input-bg: #ffffff;
  --star-off: #d8dee3;
  --ok-bg: #e6f4ea;
  --warn-bg: #fef7e0;
  --warn-ink: #b06000;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(38, 50, 56, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --brand: #ff8a3d;
  --brand-dark: #ff7a1a;
  --brand-light: #3a2715;
  --teal: #1e9a98;
  --teal-dark: #2c7a79;
  --ink: #e6edf2;
  --muted: #93a4b0;
  --bg: #12161b;
  --card: #1b2229;
  --line: #2c3842;
  --danger: #ff8b80;
  --ok: #7fd8a0;
  --danger-bg: #3a2020;
  --danger-line: #6b3333;
  --banner-bg: #3a2f13;
  --banner-line: #6b5a24;
  --banner-ink: #f0d68a;
  --input-bg: #14191e;
  --star-off: #3a444c;
  --ok-bg: #1b3324;
  --warn-bg: #3a2f13;
  --warn-ink: #f0d68a;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  position: relative;
  z-index: 1;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  background: var(--card);
  position: relative;
  z-index: 2;
}
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
}
.brand img.logo {
  height: 38px;
  width: auto;
  display: block;
  border-radius: 8px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(255, 122, 26, 0.35); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-teal { background: var(--teal); color: #fff; box-shadow: 0 4px 12px rgba(14, 124, 123, 0.3); }
.btn-teal:hover { background: var(--teal-dark); }
.btn-ghost { background: transparent; color: var(--teal); border: 1.5px solid var(--teal); }
.btn-ghost:hover { background: rgba(14, 124, 123, 0.08); }
.btn-light { background: var(--card); color: var(--teal); border: 1.5px solid var(--line); }
.btn-light:hover { background: var(--bg); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

/* ---------- Auth ---------- */
.auth-box {
  max-width: 420px;
  margin: 40px auto 0;
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tabs .tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1.5px solid var(--line);
}
.auth-tabs .tab.active { background: var(--brand-light); color: var(--brand-dark); border-color: var(--brand); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="number"], .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--ink);
  background: var(--input-bg);
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.15); }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  font-size: 15px;
  color: var(--ink);
}
.google-btn:hover { background: var(--bg); }

.consent-box {
  background: var(--brand-light);
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}
.consent-box label { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }

/* ---------- Hero / landing ---------- */
.hero { text-align: center; padding: 40px 0 20px; }
.hero h1 { font-size: 38px; margin: 0 0 12px; letter-spacing: -0.5px; }
.hero p { font-size: 17px; color: var(--muted); margin: 0 auto 26px; max-width: 560px; }
.hero .badge { display: inline-block; background: var(--teal); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; margin-bottom: 14px; }

.start-button {
  width: 130px;
  height: 130px;
  margin: 0 auto;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: radial-gradient(circle at 30% 30%, #ffa55c, var(--brand) 55%, var(--brand-dark));
  color: #fff;
  font-size: 46px;
  box-shadow: 0 12px 30px rgba(255, 122, 26, 0.45);
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  animation: float 3s ease-in-out infinite;
}
.start-button:hover { transform: scale(1.06); }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.steps-row { display: flex; gap: 14px; margin-top: 44px; flex-wrap: wrap; justify-content: center; }
.step-pill { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; flex: 1; min-width: 180px; max-width: 260px; text-align: left; }
.step-pill .num { font-size: 13px; font-weight: 800; color: var(--brand); }

/* ---------- Chat ---------- */
.chat-shell { display: flex; flex-direction: column; height: calc(100vh - 64px); max-height: 820px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.chat-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, var(--brand-light), var(--card)); }
.chat-head .avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--teal)); color: #fff; display: grid; place-items: center; font-size: 18px; }
.chat-head h2 { margin: 0; font-size: 16px; }
.chat-head small { color: var(--muted); }

.chat-log { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
.msg { max-width: 78%; padding: 11px 15px; border-radius: 16px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 4px; }
.msg.sys { align-self: center; background: var(--brand-light); color: var(--brand-dark); font-size: 13px; border-radius: 999px; padding: 7px 14px; }
.msg.invalid { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-line); }
.msg .hint { display: block; font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.chat-input { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); background: var(--card); }
.chat-input input { flex: 1; padding: 13px 16px; border: 1.5px solid var(--line); border-radius: 999px; font-size: 15px; font-family: var(--font); }
.chat-input input:focus { outline: none; border-color: var(--brand); }
.chat-input button { border-radius: 999px; }

/* ---------- Dashboard ---------- */
.shop-card { cursor: pointer; }
.shop-card .top { display: flex; align-items: center; gap: 14px; }
.shop-emoji { width: 48px; height: 48px; border-radius: 12px; background: var(--brand-light); display: grid; place-items: center; font-size: 24px; }
.shop-card h3 { margin: 0; font-size: 18px; }
.shop-card .type-tag { display: inline-block; font-size: 12px; font-weight: 700; color: var(--teal-dark); background: rgba(14,124,123,0.1); padding: 3px 10px; border-radius: 999px; margin-top: 4px; }
.shop-card .meta { color: var(--muted); font-size: 13px; margin-top: 6px; }
.shop-card .expand { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 14px; display: none; }
.shop-card.open .expand { display: block; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 10px; }
.detail-item { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.detail-item .k { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.detail-item .v { margin-top: 5px; font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.solution-box { background: linear-gradient(135deg, var(--brand-light), var(--card)); border: 1px solid var(--brand); border-radius: 12px; padding: 14px; margin-top: 14px; }
.solution-box h4 { margin: 0 0 8px; color: var(--brand-dark); }
.solution-box ul { margin: 0; padding-left: 18px; }
.solution-box li { margin-bottom: 6px; font-size: 14px; }

/* ---------- Feedback stars ---------- */
.stars { display: flex; gap: 8px; justify-content: center; font-size: 44px; cursor: pointer; user-select: none; }
.stars span { color: var(--star-off); transition: transform 0.1s, color 0.1s; }
.stars span.on { color: #ffb400; transform: scale(1.1); text-shadow: 0 2px 8px rgba(255,180,0,0.4); }

/* ---------- Gift ---------- */
.gift-stage { text-align: center; padding: 30px 0; }
.gift-box {
  width: 150px;
  height: 150px;
  margin: 0 auto 20px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: grid;
  place-items: center;
  font-size: 64px;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(255,122,26,0.4);
  transition: transform 0.2s;
  animation: float 3s ease-in-out infinite;
}
.gift-box:hover { transform: scale(1.05); }
.gift-box.opening { animation: shake 0.6s ease-in-out infinite; }
@keyframes shake { 0%,100%{transform:rotate(0)} 25%{transform:rotate(-6deg)} 75%{transform:rotate(6deg)} }

.url-field { display: flex; gap: 10px; margin-top: 14px; }
.url-field input { flex: 1; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 14px; }
.code-block { background: #0f1b22; color: #c8e6c9; border-radius: 12px; padding: 16px; font-family: Consolas, monospace; font-size: 13px; overflow-x: auto; white-space: pre; margin-top: 12px; }

/* ---------- Public site ---------- */
.public-hero { background: linear-gradient(135deg, var(--teal), #0a4f4e); color: #fff; border-radius: var(--radius); padding: 40px; text-align: center; }
.public-hero h1 { margin: 0 0 8px; font-size: 34px; }
.public-hero .chip { display: inline-block; background: rgba(255,255,255,0.18); padding: 4px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; margin-top: 8px; }
.pub-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.pub-card h3 { margin: 0 0 12px; display: flex; gap: 8px; align-items: center; }
.pub-list { margin: 0; padding: 0; list-style: none; }
.pub-list li { padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.pub-list li:last-child { border-bottom: none; }
.delivery-badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.delivery-yes { background: var(--ok-bg); color: var(--ok); }
.delivery-no { background: var(--warn-bg); color: var(--warn-ink); }

/* ---------- Widget ---------- */
#shop-rescue-widget * { box-sizing: border-box; font-family: var(--font); }
.sr-launcher {
  position: fixed; bottom: 22px; right: 22px; width: 60px; height: 60px;
  border-radius: 50%; border: none; cursor: pointer; z-index: 99999;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; font-size: 26px; box-shadow: 0 8px 22px rgba(255,122,26,0.5);
}
.sr-panel {
  position: fixed; bottom: 94px; right: 22px; width: 340px; max-width: calc(100vw - 32px);
  height: 460px; max-height: calc(100vh - 130px); border-radius: 16px; overflow: hidden;
  background: #fff; box-shadow: 0 16px 44px rgba(0,0,0,0.25); z-index: 99998;
  display: flex; flex-direction: column; border: 1px solid var(--line);
}
.sr-panel .sr-head { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: #fff; padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.sr-panel .sr-head b { font-size: 15px; }
.sr-panel .sr-head small { display: block; font-weight: 400; opacity: 0.9; }
.sr-panel .sr-close { margin-left: auto; background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }
.sr-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: #f7f9fb; }
.sr-log .sr-msg { max-width: 82%; padding: 8px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.sr-log .sr-msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.sr-log .sr-msg.user { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 3px; }
.sr-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: #fff; }
.sr-input input { flex: 1; border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; font-size: 13.5px; font-family: var(--font); }
.sr-input button { border: none; background: var(--brand); color: #fff; border-radius: 999px; padding: 0 16px; cursor: pointer; font-size: 15px; }

/* ---------- Utilities ---------- */
.muted { color: var(--muted); }
.center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.flex { display: flex; gap: 12px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.error-text { color: var(--danger); font-size: 14px; }
.hidden { display: none !important; }
.banner { background: var(--banner-bg); border: 1px solid var(--banner-line); color: var(--banner-ink); border-radius: 12px; padding: 12px 16px; font-size: 14px; margin-bottom: 16px; }
@media (max-width: 640px) {
  .hero h1 { font-size: 28px; }
  .chat-shell { height: calc(100vh - 64px); border-radius: 0; border: none; }
}
