:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#app { width: 100%; height: 100%; position: relative; }

.screen {
  width: 100%; height: 100%; position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column;
}
.screen.hidden { display: none; }

.focusable {
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer; outline: none;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

.hidden { display: none !important; }

/* ---------- Header ---------- */
.app-header {
  flex: 0 0 56px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid #26263a;
}
.app-title { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.hdr-btn {
  min-height: 44px; min-width: 72px; padding: 0 16px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Content ---------- */
.content {
  flex: 1 1 auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto;
}

/* ---------- Password card ---------- */
.pw-card {
  flex: 0 0 auto;
  min-height: 84px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 12px 16px; text-align: center;
}
.pw-text {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-weight: 600; font-size: 26px;
  color: var(--text-primary);
  word-break: break-all; line-height: 1.25; letter-spacing: 1px;
  max-height: 68px; overflow: hidden;
}
.pw-hint { font-size: 12px; color: var(--text-muted); }

/* ---------- Strength ---------- */
.strength { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }
.strength-head { display: flex; justify-content: space-between; align-items: baseline; }
.strength-label { font-size: 14px; font-weight: 700; color: var(--text-secondary); }
.strength-bits { font-size: 12px; color: var(--text-secondary); }
.strength-track {
  height: 10px; border-radius: 6px;
  background: var(--bg-tertiary); overflow: hidden;
}
.strength-fill {
  height: 100%; width: 0; border-radius: 6px;
  background: var(--text-muted);
  transition: width 0.2s ease, background 0.2s ease;
}
.strength.lvl-vweak  .strength-label { color: var(--danger); }
.strength.lvl-vweak  .strength-fill  { background: var(--danger); }
.strength.lvl-weak   .strength-label { color: #ff7a3d; }
.strength.lvl-weak   .strength-fill  { background: #ff7a3d; }
.strength.lvl-fair   .strength-label { color: #ffcc33; }
.strength.lvl-fair   .strength-fill  { background: #ffcc33; }
.strength.lvl-strong .strength-label { color: var(--accent); }
.strength.lvl-strong .strength-fill  { background: var(--accent); }
.strength.lvl-vstrong .strength-label { color: var(--accent-secondary); }
.strength.lvl-vstrong .strength-fill  { background: var(--accent-secondary); }

/* ---------- Length row ---------- */
.row {
  flex: 0 0 auto;
  min-height: 56px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  padding: 0 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.row-label { font-size: 16px; font-weight: 600; }
.len-ctl { display: flex; align-items: center; gap: 18px; }
.len-arrow { font-size: 26px; color: var(--text-secondary); line-height: 1; }
.len-val {
  font-size: 22px; font-weight: 700; min-width: 38px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.length-row:focus .len-arrow { color: var(--accent); }

/* ---------- Toggles ---------- */
.toggles {
  flex: 0 0 auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.toggle {
  min-height: 64px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 2px; padding: 0 16px; position: relative; text-align: left;
}
.toggle .t-sample {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 18px; font-weight: 700;
}
.toggle .t-name { font-size: 12px; }
.toggle .t-dot {
  position: absolute; top: 12px; right: 14px;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--text-muted); background: transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.toggle.on { background: #16222b; color: var(--text-primary); }
.toggle.on .t-sample { color: var(--accent); }
.toggle.on .t-dot {
  border-color: var(--accent); background: var(--accent);
  box-shadow: 0 0 8px var(--focus-glow);
}

/* ---------- Primary button ---------- */
.btn-primary {
  flex: 0 0 auto;
  min-height: 64px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #008fb0, #00d4ff);
  color: #04141a;
  font-size: 18px; font-weight: 800; letter-spacing: 0.5px;
  display: flex; align-items: center; justify-content: center;
}
.btn-primary:focus {
  border-color: #ffffff;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.4), 0 0 22px var(--focus-glow);
}

.hint {
  flex: 0 0 auto;
  font-size: 11px; color: var(--text-muted); text-align: center;
  letter-spacing: 0.3px;
}

/* ---------- History ---------- */
.hist-list { display: flex; flex-direction: column; gap: 10px; }
.hist-item {
  min-height: 56px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
}
.hist-pw {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px; word-break: break-all; color: var(--text-primary);
}
.hist-meta { font-size: 12px; color: var(--text-muted); flex: 0 0 auto; }
.hist-empty { color: var(--text-secondary); text-align: center; margin-top: 48px; font-size: 15px; }

/* ---------- Toast ---------- */
.toast {
  position: absolute; left: 50%; bottom: 22px;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg-tertiary); color: var(--text-primary);
  padding: 12px 24px; border-radius: 24px;
  font-size: 15px; font-weight: 600;
  border: 1px solid #2a2a40;
  opacity: 0; transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
