/* ════════════════════════════════
   Design tokens
   ════════════════════════════════ */
:root {
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --ease: cubic-bezier(.4,0,.2,1);
  --dur: .2s;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
}

/* ── Light palette ── */
body.light {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-alt: #faf9f7;
  --border: #e8e5df;
  --border-strong: #d4d0c8;
  --text: #1a1a1a;
  --text-2: #5c5c5c;
  --text-3: #9a9a9a;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-glow: rgba(99,102,241,.15);
  --success: #059669;
  --success-soft: #ecfdf5;
  --error: #dc2626;
  --error-soft: #fef2f2;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
  --shadow: 0 4px 16px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.08);
}

/* ── Dark palette ── */
body.dark {
  --bg: #111113;
  --surface: #1c1c1e;
  --surface-alt: #232326;
  --border: #2c2c2e;
  --border-strong: #3a3a3c;
  --text: #f0f0f0;
  --text-2: #a1a1a6;
  --text-3: #636366;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: rgba(129,140,248,.12);
  --accent-glow: rgba(129,140,248,.2);
  --success: #34d399;
  --success-soft: rgba(52,211,153,.1);
  --error: #f87171;
  --error-soft: rgba(248,113,113,.1);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow: 0 4px 16px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
}

/* ════════════════════════════════
   Base
   ════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.container { max-width: 1080px; width: 100%; margin: 0 auto; padding: 0 20px; }

/* ════════════════════════════════
   Header
   ════════════════════════════════ */
.header-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.brand-sub {
  font-size: .75rem;
  color: var(--text-3);
  font-weight: 500;
}
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lang-btn {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
}

/* ════════════════════════════════
   Main layout
   ════════════════════════════════ */
.main-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding-top: 28px;
  padding-bottom: 40px;
}
@media (min-width: 840px) {
  .main-layout {
    grid-template-columns: 320px 1fr;
    gap: 24px;
    align-items: start;
  }
}

/* ════════════════════════════════
   Panel (card)
   ════════════════════════════════ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease);
}
.panel:hover {
  box-shadow: var(--shadow);
}
.panel-group {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.panel-header {
  margin-bottom: 20px;
}
.panel-badge {
  display: inline-block;
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}
.panel-badge.accent {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}
.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ════════════════════════════════
   Guide panel
   ════════════════════════════════ */
.guide-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.guide-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.guide-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.guide-heading {
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.guide-text {
  font-size: .8rem;
  color: var(--text-2);
  line-height: 1.5;
}
.guide-link {
  display: inline-block;
  margin-top: 6px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}
.guide-link:hover { color: var(--accent-hover); text-decoration: underline; }

.guide-notice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 20px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-xs);
  font-size: .78rem;
  color: var(--accent);
  line-height: 1.5;
}
.guide-notice svg { flex-shrink: 0; margin-top: 2px; }

/* ════════════════════════════════
   Form fields
   ════════════════════════════════ */
.redeem-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.field {}
.field-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.field-step {
  display: inline-block;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 8px;
  vertical-align: middle;
}
.field-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.field-input {
  flex: 1;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-family: var(--font);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  outline: none;
}
.field-input::placeholder { color: var(--text-3); }
.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field-input.success {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(5,150,105,.12);
}
.field-input.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}
.field-input:disabled { opacity: .5; cursor: not-allowed; }

.field-btn {
  flex-shrink: 0;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
}
.field-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.field-btn:disabled { opacity: .4; cursor: not-allowed; }

.field-status {
  margin-top: 6px;
  font-size: .78rem;
  min-height: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.muted { color: var(--text-3); }
.text-success { color: var(--success); font-weight: 600; }
.text-error { color: var(--error); font-weight: 600; }
.text-subtle { color: var(--text-2); }

/* ════════════════════════════════
   Buttons
   ════════════════════════════════ */
.btn-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-main:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow);
}
.btn-main:active:not(:disabled) {
  transform: translateY(0);
}
.btn-main:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.form-footer {
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.task-id-line {
  font-size: .72rem;
  font-family: var(--font-mono);
  color: var(--text-3);
  word-break: break-all;
}
.note {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  color: var(--text-3);
}
.note svg { flex-shrink: 0; }

/* ════════════════════════════════
   Task panel
   ════════════════════════════════ */
.task-panel { padding: 18px 24px; }
.task-panel:hover { box-shadow: var(--shadow-sm); }
.panel-header-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--text-2);
}
.panel-title-sm {
  font-size: .9rem;
  font-weight: 600;
}

/* ════════════════════════════════
   Footer
   ════════════════════════════════ */
.footer {
  text-align: center;
  padding: 20px;
  font-size: .75rem;
  color: var(--text-3);
}

/* ════════════════════════════════
   Modal
   ════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn .15s var(--ease);
}
@keyframes fadeIn { from { opacity: 0 } }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  max-width: 400px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s var(--ease);
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0 } }

.modal-icon { font-size: 44px; line-height: 1; }
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-msg {
  font-size: .84rem;
  color: var(--text-2);
  white-space: pre-line;
  word-break: break-word;
  line-height: 1.6;
}
.modal-desc { font-size: .84rem; color: var(--text-2); }
.modal-ok { margin-top: 8px; min-width: 110px; }

/* ════════════════════════════════
   Spinner
   ════════════════════════════════ */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ════════════════════════════════
   Responsive tweaks
   ════════════════════════════════ */
@media (max-width: 480px) {
  .header-inner { height: 52px; }
  .brand-title { font-size: .95rem; }
  .panel { padding: 18px 16px; }
  .guide-num { width: 24px; height: 24px; font-size: .7rem; }
}
