/* ===== Design Tokens (from main site) ===== */
:root {
  --red: #E8192C;
  --red-light: #FF4D6A;
  --red-dark: #C01020;
  --red-glow: rgba(232, 25, 44, 0.35);
  --bg: #0A0A0A;
  --bg-alt: #111111;
  --card: rgba(255,255,255,0.03);
  --card-hover: rgba(255,255,255,0.06);
  --text-primary: #F5F5F5;
  --text-secondary: #A0A0A0;
  --text-muted: #666666;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(232, 25, 44, 0.25);
  --surface: rgba(255,255,255,0.06);
  --surface-light: rgba(255,255,255,0.1);
  --font-main: -apple-system, "PingFang SC", "Noto Sans SC", "Helvetica Neue", sans-serif;
  --transition-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --spring-bounce: cubic-bezier(0.17, 0.89, 0.32, 1.27);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #FAFAFA;
    --bg-alt: #FFFFFF;
    --card: rgba(0,0,0,0.04);
    --card-hover: rgba(0,0,0,0.07);
    --text-primary: #1A1A1A;
    --text-secondary: #555555;
    --text-muted: #999999;
    --border: rgba(0,0,0,0.1);
    --border-hover: rgba(232, 25, 44, 0.35);
    --surface: rgba(0,0,0,0.04);
    --surface-light: rgba(0,0,0,0.08);
  }
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-light); }

/* ===== Tool Header ===== */
.tool-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.tool-header .back-link {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: color 0.2s;
}
.tool-header .back-link:hover { color: var(--red); }
.tool-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}
.tool-header .brand img { height: 28px; width: auto; }
.tool-header .tool-title { flex: 1; }
.tool-header .tool-title h1 { font-size: 20px; font-weight: 700; }
.tool-header .tool-title p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ===== Instructions ===== */
.instructions {
  margin: 20px 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.instructions > details { padding: 0; }
.instructions summary {
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  color: var(--text-primary);
  background: var(--surface);
  transition: background 0.2s;
}
.instructions summary:hover { background: var(--surface-light); }
.instructions ol {
  padding: 16px 20px 16px 40px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.8;
}
.instructions ol li { margin-bottom: 4px; }

/* ===== Tool Main Area ===== */
.tool-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}
.tool-section {
  margin-bottom: 24px;
}
.tool-section label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.tool-section .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Form Elements ===== */
textarea, input[type="text"], input[type="number"], input[type="url"], select {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-family: var(--font-main);
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
  resize: vertical;
}
textarea:focus, input:focus, select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
}
textarea { min-height: 150px; }
select { cursor: pointer; appearance: none; }

input[type="file"] { font-size: 14px; width: 100%; }
input[type="file"]::file-selector-button {
  padding: 8px 16px;
  font-size: 13px;
  font-family: var(--font-main);
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-right: 12px;
  transition: all 0.2s;
}
input[type="file"]::file-selector-button:hover {
  border-color: var(--red);
  background: var(--surface-light);
}

input[type="range"] {
  width: 100%;
  height: 6px;
  appearance: none;
  background: var(--surface-light);
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  cursor: pointer;
}

input[type="checkbox"] { accent-color: var(--red); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-main);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-light); }
.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--surface-light); }
.btn-small { padding: 8px 16px; font-size: 13px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ===== Cards (Homepage) ===== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 1060px;
  margin: 0 auto;
  padding: 20px 24px;
}
@media (max-width: 900px) { .tools-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; } }
@media (max-width: 600px) { .tools-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 16px; } }

.tool-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.25s var(--transition-smooth);
  text-decoration: none;
  color: var(--text-primary);
  position: relative;
  overflow: hidden;
}
.tool-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, var(--red-glow) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}
.tool-card:hover::before { opacity: 1; }
.tool-card:hover {
  background: var(--card-hover);
  border-color: var(--red);
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(232, 25, 44, 0.12);
}
.tool-card .icon {
  font-size: 30px;
  line-height: 1;
  position: relative;
  z-index: 1;
  transition: transform 0.25s var(--spring-bounce);
}
.tool-card:hover .icon { transform: scale(1.15); }
.tool-card .name {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  position: relative;
  z-index: 1;
}
.tool-card .desc {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
  position: relative;
  z-index: 1;
  transition: color 0.2s;
}
.tool-card:hover .desc { color: var(--text-secondary); }

/* ===== Category Tabs ===== */
.category-tabs {
  display: flex;
  gap: 6px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 18px;
  flex-wrap: wrap;
  justify-content: center;
}
.category-tab {
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-main);
  background: var(--card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 18px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.category-tab:hover { border-color: var(--border-hover); color: var(--text-primary); background: var(--card-hover); }
.category-tab.active { background: var(--red); color: #fff; border-color: var(--red); }
.category-tab .count {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  color: inherit;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  font-weight: 500;
  min-width: 18px;
  text-align: center;
}
.category-tab.active .count { background: rgba(255,255,255,0.25); }

/* ===== Search ===== */
.search-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 24px 12px;
}
.search-input {
  width: 100%;
  padding: 11px 18px;
  font-size: 14px;
  font-family: var(--font-main);
  color: var(--text-primary);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  outline: none;
  transition: all 0.2s;
}
.search-input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
  background: var(--surface);
}
.search-input::placeholder { color: var(--text-muted); }

/* ===== Brand Bar ===== */
.brand-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 24px 4px;
}
.brand-bar img { height: 40px; width: auto; }
.brand-bar .brand-text { text-align: left; }
.brand-bar .brand-text h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 1.5px;
  line-height: 1.2;
}
.brand-bar .brand-text p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
  letter-spacing: 0.5px;
}

/* ===== Safety Notice ===== */
.safety-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 20px 24px 16px;
  font-size: 12px;
  color: var(--text-muted);
}
.safety-notice a { color: var(--text-secondary); text-decoration: underline; text-underline-offset: 2px; }
.safety-notice a:hover { color: var(--red); }
.safety-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--red);
  opacity: 0.6;
  display: inline-block;
}

/* ===== Footer ===== */
.tool-footer {
  text-align: center;
  padding: 32px 24px;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 40px;
}
.tool-footer a { color: var(--text-secondary); }
.tool-footer a:hover { color: var(--red); }

/* ===== Result Area ===== */
.result-area {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  min-height: 60px;
  word-break: break-all;
}
.result-area:empty { display: none; }
.result-area img { max-width: 100%; border-radius: 4px; }
.result-area pre {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== Diff View ===== */
.diff-added { background: rgba(0, 200, 80, 0.15); color: #4caf50; }
.diff-removed { background: rgba(255, 60, 60, 0.15); color: #f44336; }
.diff-equal { color: var(--text-secondary); }

/* ===== Split Layout ===== */
.split-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 600px) { .split-pane { grid-template-columns: 1fr; } }

/* ===== Range with value ===== */
.range-with-value {
  display: flex;
  align-items: center;
  gap: 12px;
}
.range-with-value input[type="range"] { flex: 1; }
.range-with-value .value {
  min-width: 48px;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: var(--red);
}

/* ===== Check-in list ===== */
.checkin-list { list-style: none; }
.checkin-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.checkin-list li:last-child { border-bottom: none; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  background: var(--text-primary);
  color: var(--bg);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  z-index: 999;
  animation: toastIn 0.3s var(--spring-bounce);
  pointer-events: none;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== Checkbox Group ===== */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
}

/* ===== Color Swatch ===== */
.color-swatch {
  display: inline-block;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid var(--border);
  vertical-align: middle;
  margin-right: 8px;
}

/* ===== Highlight Match ===== */
.highlight-match {
  background: var(--red-glow);
  border-radius: 2px;
  padding: 0 2px;
}

/* ===== Privacy Page ===== */
.privacy-content {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 24px;
}
.privacy-content h2 {
  font-size: 20px;
  margin: 32px 0 12px;
}
.privacy-content p, .privacy-content li {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 8px;
}
.privacy-content ul { padding-left: 24px; }

/* ===== Color Input ===== */
input[type="color"] {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  padding: 2px;
}

/* ===== Inline Flex Row ===== */
.inline-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.inline-row > * { flex: 1; min-width: 120px; }

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}
.stat-item .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--red);
}
.stat-item .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Group Result ===== */
.group-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.group-card h3 {
  font-size: 14px;
  color: var(--red);
  margin-bottom: 8px;
}
.group-card ol {
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== QR Preview ===== */
.qr-preview-wrap {
  display: flex;
  justify-content: center;
  padding: 20px;
  background: #fff;
  border-radius: var(--radius-md);
}
.qr-preview-wrap canvas, .qr-preview-wrap img {
  display: block;
}

/* ===== Batch QR Grid ===== */
.batch-qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.batch-qr-item {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.batch-qr-item canvas { display: block; margin: 0 auto; }
.batch-qr-item .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  word-break: break-all;
}

/* ===== Draw Animation ===== */
.draw-animation {
  font-size: 48px;
  font-weight: 700;
  text-align: center;
  padding: 32px;
  color: var(--red);
  animation: drawPop 0.5s var(--spring-bounce);
}
@keyframes drawPop {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ===== Tabs (within tool) ===== */
.tool-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}
.tool-tab {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-main);
  background: none;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.2s;
}
.tool-tab:hover { color: var(--text-primary); }
.tool-tab.active { color: var(--red); border-bottom-color: var(--red); }
