:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --border: #334155;
  --accent: #3b82f6;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --text: #f8fafc;
  --muted: #94a3b8;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
body {
  padding-bottom: 110px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #0b1120;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 10px;
  flex-wrap: wrap;
}
.brand {
  font-size: 18px;
  font-weight: 800;
  color: white;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.lang-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lang-select {
  width: auto !important;
  min-height: 38px;
  padding: 6px 10px !important;
  font-size: 13px !important;
  border-radius: 8px;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  cursor: pointer;
}
.nav-tabs {
  display: flex;
  gap: 8px;
  width: 100%;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.nav-tabs button, .nav-tabs a {
  background: #131c31;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 10px 14px;
  min-height: 44px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-tabs button.active, .nav-tabs a.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 700;
}
.container {
  max-width: 1140px;
  margin: 20px auto;
  padding: 0 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
}
.card h2, .card h3 { margin-top: 0; }
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 18px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 14px;
}
.stat-box {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-box .label { font-size: 12px; color: var(--muted); }
.stat-box .val { font-size: 20px; font-weight: 800; margin-top: 4px; word-break: break-word; }
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0 5px;
  color: #cbd5e1;
}
input[type="text"], input[type="email"], select, textarea {
  width: 100%;
  padding: 11px 12px;
  min-height: 46px;
  border-radius: 9px;
  border: 1px solid #475569;
  background: #0f172a;
  color: white;
  font-size: 16px; /* 16px prevents iOS Safari auto-zoom on focus */
}
textarea.code-input {
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 16px;
  min-height: 46px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  line-height: 1.3;
}
.btn-primary { background: var(--accent); color: white; }
.btn-success { background: var(--green); color: #052e16; }
.btn-warning { background: var(--yellow); color: #0f172a; }
.btn-danger { background: var(--red); color: white; }
.btn-ghost { background: #334155; color: white; }
.btn-hero-paste {
  width: 100%;
  min-height: 58px;
  font-size: 16px;
  font-weight: 800;
  background: linear-gradient(135deg, #10b981 0%, #2563eb 100%);
  color: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
  border: 1px solid #34d399;
}
.ai-helper-card {
  background: linear-gradient(180deg, rgba(30, 58, 138, 0.45) 0%, rgba(30, 41, 59, 0.95) 100%);
  border: 2px solid #3b82f6;
}
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
}
.badge-green { background: rgba(16,185,129,0.2); color: #34d399; }
.badge-yellow { background: rgba(245,158,11,0.2); color: #fbbf24; }
.badge-red { background: rgba(239,68,68,0.25); color: #f87171; }
.badge-blue { background: rgba(59,130,246,0.2); color: #60a5fa; }
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  word-break: break-word;
}
.alert-info { background: #1e3a8a; color: #bfdbfe; border: 1px solid #3b82f6; }
.alert-error { background: #7f1d1d; color: #fecaca; border: 1px solid #ef4444; }
.alert-success { background: #064e3b; color: #a7f3d0; border: 1px solid #10b981; }
.hidden { display: none !important; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
code {
  background: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  color: #38bdf8;
  font-family: Consolas, monospace;
  word-break: break-all;
}
.app-footer {
  max-width: 1140px;
  margin: 28px auto 16px;
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

/* Mobile-First RWD: 手機螢幕 (< 768px) 自動將表格轉為垂直卡片堆疊，按鈕滿版易按 */
@media (max-width: 768px) {
  .topbar { padding: 10px 12px; }
  .container { padding: 0 12px; margin: 14px auto; }
  .card { padding: 16px; }
  .btn { min-height: 48px; }
  table.responsive-table,
  table.responsive-table tbody {
    display: block;
    width: 100%;
  }
  table.responsive-table thead {
    display: none;
  }
  table.responsive-table tr {
    display: block;
    background: #0f172a;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
  }
  table.responsive-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed #334155;
    flex-wrap: wrap;
    gap: 8px;
  }
  table.responsive-table td:last-child {
    border-bottom: none;
    padding-top: 12px;
  }
  table.responsive-table td::before {
    content: attr(data-label);
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
  }
}
