/* ============================================================
   KeyForge — 2FA & Security Toolkit
   Premium Security Design System v4.3
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
  --bg: #F8FAFC;
  --bg-secondary: #F1F5F9;
  --surface: #FFFFFF;
  --surface-hover: #F8FAFC;
  --border: #E2E8F0;
  --border-focus: #1E40AF;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-tertiary: #94A3B8;
  --primary: #1E40AF;
  --primary-hover: #1E3A8A;
  --primary-light: #DBEAFE;
  --primary-bg: #EFF6FF;
  --success: #059669;
  --success-light: #D1FAE5;
  --warning: #D97706;
  --warning-light: #FEF3C7;
  --danger: #DC2626;
  --danger-light: #FEE2E2;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
  --shadow-md: 0 4px 6px -1px rgba(15,23,42,0.08), 0 2px 4px -2px rgba(15,23,42,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15,23,42,0.1), 0 4px 6px -4px rgba(15,23,42,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(15,23,42,0.1), 0 8px 10px -6px rgba(15,23,42,0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --nav-height: 68px;
  --content-max: 1280px;
  --sidebar-width: 240px;
  --toast-bg: #0F172A;
  --toast-text: #FFFFFF;
  --overlay: rgba(15,23,42,0.6);
}

[data-theme="dark"] {
  --bg: #0F172A;
  --bg-secondary: #1E293B;
  --surface: #1E293B;
  --surface-hover: #334155;
  --border: #334155;
  --border-focus: #3B82F6;
  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-tertiary: #64748B;
  --primary: #3B82F6;
  --primary-hover: #60A5FA;
  --primary-light: #1E3A8A;
  --primary-bg: #172554;
  --success: #10B981;
  --success-light: #064E3B;
  --warning: #F59E0B;
  --warning-light: #78350F;
  --danger: #EF4444;
  --danger-light: #7F1D1D;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.35), 0 2px 4px -2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.35);
  --toast-bg: #F1F5F9;
  --toast-text: #0F172A;
  --overlay: rgba(0,0,0,0.7);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Typography --- */
h1 { font-size: 32px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 24px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
h3 { font-size: 20px; font-weight: 600; line-height: 1.4; }
.label { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; display: block; text-transform: uppercase; letter-spacing: 0.05em; }
.caption { font-size: 12px; color: var(--text-tertiary); }

/* --- Navigation --- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-sm);
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand-mark { flex-shrink: 0; }
.brand-text { font-weight: 700; }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 15px;
}
.nav-btn:hover { background: var(--surface-hover); color: var(--text); }
.lang-btn { width: auto; padding: 0 16px; font-size: 13px; font-weight: 600; }

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
  z-index: 90;
}
.sidebar-inner { display: flex; flex-direction: column; gap: 4px; }
.sidebar .tab-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  border-radius: var(--radius-md);
  transition: all var(--transition);
  text-align: left;
  width: 100%;
}
.sidebar .tab-btn:hover { background: var(--bg-secondary); color: var(--text); }
.sidebar .tab-btn.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.25);
}
.sidebar .tab-btn i {
  flex-shrink: 0;
  width: 20px !important;
  height: 20px !important;
}

/* --- Mobile Tab Bar --- */
.mobile-tabs {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 4px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.mobile-tabs::-webkit-scrollbar { display: none; }
.mobile-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
  white-space: nowrap;
  min-width: 60px;
  scroll-snap-align: center;
  touch-action: manipulation;
}
.mobile-tab.active { color: var(--primary); font-weight: 700; }
.mobile-tab:active { transform: scale(0.96); }

/* --- Layout --- */
.layout {
  display: flex;
  min-height: calc(100vh - var(--nav-height));
}
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  max-width: var(--content-max);
  width: 100%;
  padding: 16px 20px;
  box-sizing: border-box;
  margin-right: auto;
  overflow: visible;
}
.tool-panel {
  display: none;
  animation: fadeIn 180ms ease-out;
}
.tool-panel.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}
.card:hover { border-color: #CBD5E1; }
[data-theme="dark"] .card:hover { border-color: #475569; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-icon.success {
  background: var(--success-light);
  color: var(--success);
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* --- Form Controls --- */
.form-group { margin-bottom: 12px; }
.form-row { display: flex; gap: 12px; }

/* 统一表单元素最大宽度，解决输入框太宽导致按钮距离远的问题 */
.form-group,
.input-wrapper,
.input,
textarea.input,
.select,
.range-row,
.option-grid,
.toggle-group,
.config-grid,
.result-row,
.btn.w-full {
  max-width: 400px;
}

/* 让卡片内部表单内容左对齐 */
.card .form-group,
.card .input-wrapper,
.card .range-row,
.card .option-grid,
.card .toggle-group,
.card .config-grid,
.card .result-row,
.card .btn.w-full {
  margin-left: 0;
  margin-right: auto;
}

/* 大屏下进一步收窄表单内容 */
@media (min-width: 1200px) {
  .form-group,
  .input-wrapper,
  .input,
  textarea.input,
  .select,
  .range-row,
  .option-grid,
  .toggle-group,
  .config-grid,
  .result-row,
  .btn.w-full {
    max-width: 360px;
  }
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}
.input-wrapper .input { flex: 1; min-width: 0; }
.input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition);
}
.input:focus {
  border-color: var(--border-focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(30,64,175,0.08);
}
.input::placeholder { color: var(--text-tertiary); }
.input-mono { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.02em; }
textarea.input { height: auto; min-height: 80px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.input-with-btn {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  border-right: none !important;
}
.input-icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all var(--transition);
  flex-shrink: 0;
  cursor: pointer;
}
.input-icon-btn:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.input-icon-btn:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.input-icon-btn:not(:first-child) { border-left: none; }
.input-icon-btn:hover { background: var(--surface-hover); color: var(--primary); }

/* --- Counter Controls --- */
.counter-controls {
  display: flex;
  align-items: center;
  gap: 0;
}
.counter-input {
  text-align: center;
  border-radius: 0;
  border-left: none;
  border-right: none;
  width: 80px;
  flex-shrink: 0;
}

/* --- Select --- */
.select {
  height: 48px;
  padding: 0 40px 0 16px;
  font-size: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364758B' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  cursor: pointer;
  transition: all var(--transition);
}
.select:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(30,64,175,0.08); }

/* --- Switch --- */
.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  user-select: none;
}
.switch input { display: none; }
.switch-track {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--primary); color: #FFFFFF; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--bg-secondary); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--text-tertiary); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #FFFFFF; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 11px; border-radius: var(--radius-sm); }
.btn-icon { width: 36px; padding: 0; }
.w-full { width: 100%; }
.flex-1 { flex: 1; }

/* --- Toggle Groups --- */
.toggle-group {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}
.toggle-item {
  flex: 1;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
  padding: 0 12px;
  white-space: nowrap;
}
.toggle-item.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}
.toggle-item:hover:not(.active) { color: var(--text); }

/* --- Option Grid --- */
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}
.option-btn {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.option-btn:hover { border-color: var(--text-tertiary); color: var(--text); }
.option-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

/* --- OTP Display --- */
.otp-display { text-align: center; }
.otp-code {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--primary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  line-height: 1;
  margin-bottom: 4px;
}
.otp-code:hover { transform: scale(1.02); opacity: 0.9; }
.otp-code:active { transform: scale(1.01); }
.otp-hint { font-size: 11px; color: var(--text-tertiary); }

/* --- Timer Ring --- */
.timer-ring { position: relative; }
.timer-ring svg { transform: rotate(-90deg); }
.timer-ring-bg { fill: none; stroke: var(--border); stroke-width: 2; }
.timer-ring-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}
.timer-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
}

/* --- Counter Display --- */
.counter-display {
  text-align: center;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.counter-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 2px;
}

/* --- Strength Bar --- */
.strength-section { margin-top: 16px; }
.strength-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.strength-bar {
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.strength-fill { height: 100%; border-radius: var(--radius-full); transition: width 300ms ease, background-color 300ms ease; }
.strength-weak { background: var(--danger); }
.strength-fair { background: var(--warning); }
.strength-good { background: var(--primary); }
.strength-strong { background: var(--success); }
.strength-label { font-size: 13px; font-weight: 600; }

/* --- Result Display --- */
.result-main {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 32px;
  margin-bottom: 12px;
}
.result-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  line-height: 1.5;
  color: var(--text);
  max-height: 120px;
  overflow-y: auto;
}
.result-row { display: flex; align-items: stretch; gap: 0; }
.result-row .result-box { flex: 1; border-radius: var(--radius-md) 0 0 var(--radius-md); }
.result-copy-btn {
  width: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.result-copy-btn:hover { background: var(--surface-hover); color: var(--primary); }

/* --- OTP Controls --- */
.otp-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* TOTP/HOTP结果区域特殊约束 */
#totpResult .result-row,
#hotpResult .result-row {
  max-width: 400px;
}

#totpNormalizedWrap .result-box {
  white-space: nowrap;
  overflow-x: auto;
  word-break: normal;
}

/* 确保OTP控制区域不超出卡片 */
#totpResult .otp-controls,
#hotpResult .otp-controls {
  max-width: 100%;
}

/* --- QR Section --- */
.qr-section {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.qr-container {
  flex-shrink: 0;
}
.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 8px;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.qr-wrap canvas, .qr-wrap img, .qr-wrap svg { display: block; width: 120px; height: 120px; }
.qr-info {
  flex: 1;
  min-width: 0;
}

/* --- Range Slider --- */
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: var(--radius-full);
  outline: none;
}
.range-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition);
}
.range-row input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
.range-value {
  min-width: 44px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

/* --- File Input --- */
.file-input-wrapper {
  position: relative;
}
.file-input-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
}
.file-input-display:hover {
  border-color: var(--border-focus);
  background: var(--surface);
}

/* --- Checkbox Group --- */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- UUID List --- */
.uuid-list {
  min-height: 60px;
  max-width: 400px;
}
.uuid-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.uuid-row:last-child { border-bottom: none; }
.uuid-text {
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  flex: 1;
  color: var(--text);
  line-height: 1.5;
}

/* UUID操作按钮约束 */
#uuidResultCard .action-row {
  max-width: 400px;
}

/* --- Action Rows --- */
.action-row {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

/* --- Swap Button --- */
.swap-button {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--toast-bg);
  color: var(--toast-text);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-xl);
  animation: toastIn 180ms ease-out;
  pointer-events: auto;
  white-space: nowrap;
}
.toast.toast-out { animation: toastOut 180ms ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-12px); } }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 150ms ease-out;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn 200ms ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 0;
}
.modal-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 24px 24px;
}

/* --- Advanced Toggle --- */
.advanced-toggle { margin-bottom: 16px; }
.advanced-panel { padding: 8px 0; }

/* --- Config Grid --- */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}
.config-item { display: flex; flex-direction: column; gap: 8px; }

/* --- Vault --- */
.vault-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 12px;
}
.vault-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--warning);
  background: var(--warning-light);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}
.vault-list { display: flex; flex-direction: column; gap: 8px; }
.vault-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition);
}
.vault-item:hover { border-color: var(--text-tertiary); }
.vault-item-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.vault-item-info { flex: 1; min-width: 0; }
.vault-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vault-item-issuer {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vault-item-otp {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity var(--transition);
}
.vault-item-otp:hover { opacity: 0.75; }
.vault-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.vault-timer { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.vault-timer-ring { position: relative; width: 24px; height: 24px; }
.vault-timer-ring svg { transform: rotate(-90deg); }
.vault-timer-ring-bg { fill: none; stroke: var(--border); stroke-width: 2; }
.vault-timer-ring-progress { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; transition: stroke-dashoffset 400ms linear; }
.vault-timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-secondary);
}
.empty-icon {
  margin: 0 auto 12px;
  opacity: 0.3;
}
.empty-state p {
  font-size: 13px;
  margin-bottom: 12px;
}

/* --- Inline Actions --- */
.inline-actions { display: flex; gap: 10px; align-items: center; }

/* --- Entropy Badge --- */
.entropy-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* --- Footer --- */
.footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.footer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* --- Spacing Utilities --- */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.text-center { text-align: center; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-tabs { display: flex; justify-content: space-around; }
  .main { margin-left: 0; padding: 12px 16px; padding-bottom: 80px; }
  .card { padding: 12px; margin-bottom: 8px; }
  .otp-code { font-size: 28px; }
  .nav-brand .brand-text { display: none; }
  .option-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
  .modal { max-width: 100%; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; align-self: flex-end; }
  .config-grid { grid-template-columns: 1fr; }
  .qr-section { flex-direction: column; align-items: center; }
  .qr-info { text-align: center; }
  .result-main { flex-direction: column; text-align: center; }
  .otp-controls { flex-direction: column; }
  .vault-header { flex-direction: column; align-items: stretch; }
  .inline-actions { justify-content: center; }
}

@media (min-width: 1024px) {
  .main { padding: 40px 32px; }
}

@media (min-width: 1400px) {
  .main { padding-left: 48px; padding-right: 48px; }
  .card { padding: 28px; }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

::selection { background: var(--primary); color: white; }

@media print {
  .nav, .sidebar, .mobile-tabs, .footer, .toast-container { display: none !important; }
  .main { max-width: 100%; margin-left: 0; }
}

/* --- Focus Styles --- */
button:focus-visible,
input:focus-visible,
select:focus-visible,
.toggle-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* --- UUID Controls --- */
.uuid-controls {
  display: flex;
  gap: 16px;
  align-items: end;
  flex-wrap: wrap;
}
.count-input {
  min-width: 120px;
}

/* --- File Input Display --- */
.file-input-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
}
.file-input-display:hover {
  border-color: var(--border-focus);
  background: var(--surface);
}

/* --- Strength Bar Enhanced --- */
.strength-fill { height: 100%; border-radius: var(--radius-full); transition: width 300ms ease, background-color 300ms ease; }
/* --- Vault Actions (v4.3 Enterprise) --- */
.vault-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* --- Modal Form Overrides (remove max-width inside modal) --- */
.modal .form-group,
.modal .input-wrapper,
.modal .input,
.modal textarea.input,
.modal .select,
.modal .toggle-group,
.modal .result-row,
.modal .btn.w-full {
  max-width: none;
}

/* --- Nav polish --- */
.nav {
  background: rgba(255,255,255,0.92);
}
[data-theme="dark"] .nav {
  background: rgba(30,41,59,0.92);
}

/* --- Card hover refined --- */
.card {
  box-shadow: var(--shadow-sm);
}
.card:hover {
  box-shadow: var(--shadow-md);
}

/* --- Sidebar active refined --- */
.sidebar .tab-btn.active {
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.2);
}

/* --- Vault item polish --- */
.vault-item {
  transition: all var(--transition), box-shadow var(--transition);
}
.vault-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* --- Empty state polish --- */
.empty-state {
  padding: 48px 16px;
}
.empty-icon {
  opacity: 0.2;
  margin-bottom: 16px;
}

/* --- OTP code size refinement for large screens --- */
@media (min-width: 1024px) {
  .otp-code {
    font-size: 36px;
    letter-spacing: 4px;
  }
}

/* --- Select height fix --- */
.select {
  height: 40px;
}

/* --- Vault notice margin --- */
.vault-notice {
  margin-bottom: 16px;
}

/* --- Scrollbar on dark mode --- */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #475569;
}
