:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --ink: #18232d;
  --muted: #82909b;
  --line: #e4e9ee;
  --green: #159447;
  --green-dark: #0e7336;
  --green-pale: #eaf7ef;
  --coral: #c85b4f;
  --shadow: 0 16px 42px rgba(28, 45, 60, .07);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 30px 0 22px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 34px; }
.brand-lockup, .top-actions, .offline-status, .button-row, .panel-heading, .list-heading, .history-heading { display: flex; align-items: center; }
.brand-lockup { gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: white; background: var(--green); border-radius: 12px; font-size: 21px; box-shadow: 0 7px 16px rgba(21, 148, 71, .2); }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 18px; letter-spacing: .2px; }
.brand-lockup p { color: var(--muted); font-size: 12px; margin-top: 2px; }
.top-actions { gap: 9px; }
.data-button { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; transition: .2s; }
.data-button:hover { color: var(--green); border-color: #b8dbc4; background: var(--green-pale); }
.offline-status { gap: 7px; margin-left: 9px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-pale); }
.hero-band { display: flex; justify-content: space-between; align-items: end; min-height: 172px; padding: 27px 35px 29px; overflow: hidden; border-radius: 14px; color: white; background: linear-gradient(115deg, #163b2a 0%, #1b6540 58%, #269b59 100%); box-shadow: var(--shadow); position: relative; }
.hero-band::after { content: "✦"; position: absolute; right: 33%; top: -35px; color: rgba(255,255,255,.07); font-size: 220px; transform: rotate(18deg); pointer-events: none; }
.eyebrow, .section-kicker { color: #8bd8a7; font-size: 10px; font-weight: 700; letter-spacing: 1.8px; }
.hero-band h2 { margin: 9px 0 8px; font-size: clamp(28px, 4vw, 43px); font-weight: 300; letter-spacing: 0; }
.hero-band h2 em { color: #a8edbc; font-style: normal; font-weight: 700; }
.hero-copy { color: rgba(255,255,255,.72); font-size: 13px; }
.hero-stat { position: relative; z-index: 1; min-width: 150px; padding-left: 28px; border-left: 1px solid rgba(255,255,255,.24); }
.hero-stat span { display: block; font-size: 46px; line-height: 1; font-weight: 700; }
.hero-stat small { color: rgba(255,255,255,.68); font-size: 12px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px; margin-top: 18px; }
.panel { min-width: 0; padding: 25px 27px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.panel-heading { justify-content: space-between; margin-bottom: 22px; }
.section-kicker { display: block; color: var(--muted); margin-bottom: 5px; }
h3 { font-size: 20px; letter-spacing: 0; }
h4 { font-size: 14px; }
.count-pill, .draw-badge, .record-count { color: var(--green); background: var(--green-pale); border-radius: 99px; padding: 6px 10px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.field-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
textarea { display: block; width: 100%; height: 178px; resize: vertical; padding: 13px 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fbfcfd; outline: none; font-size: 13px; line-height: 1.7; transition: .2s; }
textarea:focus { border-color: #74c18d; box-shadow: 0 0 0 3px rgba(21, 148, 71, .1); background: white; }
textarea::placeholder { color: #b6bfc7; }
.input-hint { min-height: 31px; padding-top: 7px; color: var(--muted); font-size: 11px; }
.button-row { gap: 8px; }
.button { min-height: 38px; flex: 1; border: 1px solid transparent; border-radius: 7px; font-size: 12px; font-weight: 700; transition: .2s; }
.button.primary { color: white; background: var(--green); }
.button.primary:hover, .draw-button:hover { background: var(--green-dark); transform: translateY(-1px); box-shadow: 0 7px 16px rgba(21, 148, 71, .2); }
.button.subtle, .reset-button { color: var(--ink); border-color: var(--line); background: #f5f7f9; }
.button.subtle:hover, .reset-button:hover { background: #ebeff2; }
.list-heading, .history-heading { justify-content: space-between; margin: 26px 0 10px; }
.text-button { padding: 0; border: 0; background: transparent; font-size: 11px; font-weight: 700; }
.danger { color: var(--coral); }
.danger:hover { color: #a83f36; }
.list-wrap { height: 285px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; }
ul { list-style: none; padding: 0; margin: 0; }
.name-list li, .history-list li {
  min-height: 44px;
  padding: 9px 13px;
  border-bottom: 1px solid #edf0f2;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.name-list li:last-child, .history-list li:last-child { border-bottom: 0; }
.name-list li { display: flex; align-items: flex-start; gap: 9px; }
.name-list .name-text { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.name-list li::before { content: ""; width: 6px; height: 6px; flex: none; margin-top: 9px; border-radius: 50%; background: #b7c1c9; }
.name-list li.selected { color: var(--green-dark); background: var(--green-pale); }
.name-list li.selected::before { background: var(--green); }
.empty-state { justify-content: center; min-height: 100%; color: #aab4bc; font-size: 12px; }
.empty-state::before { display: none; }
.winner-stage { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 174px; margin-bottom: 15px; padding: 20px; border: 1px solid #d9eee0; border-radius: 12px; text-align: center; background: linear-gradient(145deg, #f3fbf5, #e8f6ed); }
.winner-label { color: var(--green); font-size: 11px; font-weight: 700; letter-spacing: 1px; }
.winner-stage strong { max-width: 100%; margin: 9px 0 4px; overflow-wrap: anywhere; color: var(--green-dark); font-size: clamp(26px, 4vw, 40px); line-height: 1.15; }
.winner-subtitle { color: var(--muted); font-size: 12px; }
.winner-stage.is-drawing strong { animation: pulse .55s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .45; transform: scale(.97); } }
.draw-button { display: block; width: 100%; min-height: 54px; border: 0; border-radius: 8px; color: white; background: var(--green); font-size: 15px; font-weight: 700; transition: .2s; }
.draw-icon { margin-right: 7px; font-size: 18px; }
.reset-button { display: block; width: 100%; min-height: 36px; margin-top: 9px; border-radius: 7px; font-size: 12px; transition: .2s; }
.history-heading { margin-top: 27px; }
.history-wrap { height: 170px; }
.history-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 12px;
  row-gap: 3px;
  align-items: start;
  color: var(--ink);
}
.history-list time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.history-list .history-name { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.footer-note { padding-top: 17px; color: var(--muted); text-align: center; font-size: 11px; }
.footer-note span { color: var(--green); font-size: 15px; vertical-align: -1px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 5; padding: 11px 15px; border: 1px solid #cfe5d6; border-radius: 8px; color: var(--green-dark); background: white; box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 760px) {
  .app-shell { width: min(100% - 26px, 580px); padding-top: 18px; }
  .topbar { margin-bottom: 22px; }
  .offline-status { display: none; }
  .hero-band { min-height: 205px; padding: 24px; align-items: start; }
  .hero-stat { position: absolute; right: 24px; bottom: 24px; padding-left: 15px; }
  .hero-stat span { font-size: 32px; }
  .hero-copy { max-width: 72%; line-height: 1.6; }
  .workspace { grid-template-columns: 1fr; }
  .panel { padding: 21px; }
  textarea { height: 150px; }
  .list-wrap { height: 210px; }
}
