/* ===== Variables (Light) ===== */
:root {
  --primary:    #6366f1;
  --primary-h:  #4f46e5;
  --danger:     #ef4444;
  --success:    #22c55e;
  --bg:         #f8fafc;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --text-muted: #64748b;
  --code-bg:    #f1f5f9;
  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --transition: .18s ease;

  /* Strength colors */
  --s0: #ef4444;
  --s1: #f97316;
  --s2: #eab308;
  --s3: #22c55e;
  --s4: #0ea5e9;
}

/* ===== Dark Mode ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #0f172a;
    --surface:    #1e293b;
    --border:     #334155;
    --text:       #f1f5f9;
    --text-muted: #94a3b8;
    --code-bg:    #0f172a;
  }
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Hiragino Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Header ===== */
.site-header {
  background: linear-gradient(135deg, var(--primary) 0%, #4338ca 100%);
  color: #fff;
  padding: 1.75rem 1.5rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(99,102,241,.4);
}
.site-header h1 { font-size: clamp(1.3rem, 4vw, 1.9rem); font-weight: 700; }
.site-header p  { margin-top: .35rem; font-size: .82rem; opacity: .88; }

/* ===== Layout ===== */
main { padding: 2rem 1rem 3rem; }
.container {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.left-col, .right-col { display: flex; flex-direction: column; gap: 1.25rem; }

/* ===== Card ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  gap: .15rem;
}
.tab {
  flex: 1;
  padding: .55rem .4rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color var(--transition);
}
.tab:hover  { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Form Fields ===== */
.field { margin-bottom: 1rem; }
.field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: .4rem;
  color: var(--text);
}

/* ===== Range Slider ===== */
.range-field label strong { font-size: 1.1rem; color: var(--primary); }
input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
  height: 6px;
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ===== Checkboxes ===== */
.checkboxes { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  cursor: pointer;
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.ambiguous { margin-top: .25rem; padding-top: .75rem; border-top: 1px dashed var(--border); }
.chars-example { font-family: monospace; font-size: .8rem; color: var(--text-muted); }

/* ===== Segmented Buttons ===== */
.seg-buttons {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.seg {
  flex: 1;
  padding: .45rem .5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border-right: 1px solid var(--border);
}
.seg:last-child { border-right: none; }
.seg:hover  { background: var(--code-bg); color: var(--text); }
.seg.active { background: var(--primary); color: #fff; }

/* ===== Mode Notes ===== */
.mode-note {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .75rem;
}
.mode-note code {
  background: var(--code-bg);
  padding: .2rem .5rem;
  border-radius: 4px;
  font-size: .8rem;
  color: var(--primary);
}

/* ===== Generate Card ===== */
.generate-card { display: flex; flex-direction: column; gap: .75rem; }
.btn-primary {
  width: 100%;
  padding: .8rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(99,102,241,.35);
}
.btn-primary:hover  { background: var(--primary-h); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,.4); }
.btn-primary:active { transform: translateY(0); }

.bulk-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.bulk-label { font-size: .8rem; color: var(--text-muted); white-space: nowrap; }
.btn-bulk {
  flex: 1;
  padding: .45rem .5rem;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-bulk:hover { border-color: var(--primary); color: var(--primary); background: rgba(99,102,241,.06); }

/* ===== Result Card ===== */
.result-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}
.password-display {
  flex: 1;
  font-family: 'Courier New', Consolas, monospace;
  font-size: clamp(.85rem, 2vw, 1.1rem);
  background: var(--code-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .7rem .9rem;
  word-break: break-all;
  min-height: 3.2rem;
  line-height: 1.5;
}

.btn-copy {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
}
.btn-copy:hover { border-color: var(--primary); color: var(--primary); }
.btn-copy.copied { border-color: var(--success); color: var(--success); background: rgba(34,197,94,.08); }

/* ===== Strength Meter ===== */
.strength-area {}
.strength-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: .4rem;
}
.strength-bar {
  height: 100%;
  border-radius: 99px;
  width: 0;
  transition: width .4s ease, background-color .4s ease;
}
.strength-meta {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
}
.strength-label { font-weight: 700; }
.strength-time  { color: var(--text-muted); }

/* ===== Bulk Card ===== */
.bulk-header, .history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.bulk-header h2, .history-header h2 { font-size: .95rem; font-weight: 700; }
.history-count { font-size: .8rem; color: var(--text-muted); font-weight: 400; }

.bulk-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.bulk-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .6rem;
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: .82rem;
}
.bulk-item-pw { flex: 1; word-break: break-all; }
.bulk-copy {
  flex-shrink: 0;
  padding: .2rem .5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 4px;
  font-size: .72rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}
.bulk-copy:hover { color: var(--primary); border-color: var(--primary); }

/* ===== History ===== */
.history-note {
  font-size: .75rem;
  color: var(--text-muted);
  background: rgba(99,102,241,.06);
  border-left: 3px solid var(--primary);
  padding: .5rem .75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: .75rem;
}

.history-list { list-style: none; display: flex; flex-direction: column; gap: .35rem; }
.history-empty { font-size: .82rem; color: var(--text-muted); text-align: center; padding: 1rem; }

.history-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .8rem;
}
.history-pw {
  flex: 1;
  font-family: monospace;
  cursor: pointer;
  word-break: break-all;
  letter-spacing: .05em;
}
.history-pw.masked { filter: blur(4px); transition: filter .2s; }
.history-pw.masked:hover { filter: blur(0); }
.history-copy {
  flex-shrink: 0;
  padding: .2rem .5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 4px;
  font-size: .72rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}
.history-copy:hover { color: var(--primary); border-color: var(--primary); }

/* ===== Utility Buttons ===== */
.btn-sm {
  padding: .3rem .65rem;
  font-size: .75rem;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-sm:hover { background: var(--code-bg); }
.btn-sm.danger { border-color: var(--danger); color: var(--danger); }
.btn-sm.danger:hover { background: rgba(239,68,68,.06); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #0f172a;
  color: #f1f5f9;
  padding: .65rem 1.5rem;
  border-radius: 100px;
  font-size: .82rem;
  opacity: 0;
  pointer-events: none;
  transition: all .3s cubic-bezier(.34,1.56,.64,1);
  z-index: 9999;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  font-size: .75rem;
  color: var(--text-muted);
}
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ===== Responsive ===== */
@media (max-width: 780px) {
  .container { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .tab { font-size: .75rem; padding: .5rem .3rem; }
  .bulk-row { flex-wrap: wrap; }
}
