/* ==========================================================================
   WormYan Design System
   Modern, Device-Independent Personal Web Portal
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties / Design Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Color Palette - High-Contrast Dark Slate & Cyan/Emerald Accents */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-surface: #1e293b;
  --bg-surface-hover: #273549;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-card-hover: rgba(39, 53, 73, 0.95);
  --bg-glass: rgba(15, 23, 42, 0.8);
  --bg-input: #0f172a;

  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-active: rgba(56, 189, 248, 0.5);

  /* Typography Colors */
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Accent Colors */
  --accent-cyan: #38bdf8;
  --accent-cyan-hover: #0ea5e9;
  --accent-cyan-bg: rgba(56, 189, 248, 0.12);
  --accent-cyan-border: rgba(56, 189, 248, 0.35);

  --accent-emerald: #22c55e;
  --accent-emerald-bg: rgba(34, 197, 94, 0.12);
  --accent-emerald-border: rgba(34, 197, 94, 0.35);

  --accent-amber: #f59e0b;
  --accent-amber-bg: rgba(245, 158, 11, 0.12);
  --accent-rose: #f43f5e;
  --accent-rose-bg: rgba(244, 63, 94, 0.12);
  --accent-indigo: #818cf8;
  --accent-purple: #c084fc;

  /* Elevation & Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.2);

  /* Layout Spacing */
  --nav-height-primary: 64px;
  --nav-height-secondary: 52px;
  --header-height-total: 116px;
  --container-max-width: 1440px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode Overrides (Optional Toggle) */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --bg-input: #ffffff;

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.16);
  --border-active: rgba(2, 132, 199, 0.5);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --accent-cyan: #0284c7;
  --accent-cyan-bg: rgba(2, 132, 199, 0.1);
  --accent-cyan-border: rgba(2, 132, 199, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* --------------------------------------------------------------------------
   2. Reset & Base Styles
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  min-height: 100vh;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
  user-select: none;
}

/* --------------------------------------------------------------------------
   3. Sticky Two-Level Header & Navigation
   -------------------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Level 1: Primary Navigation Bar --- */
.nav-primary {
  height: var(--nav-height-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  gap: 16px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-logo img {
  width: 36px;
  height: 36px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

.brand-title-group {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-domain {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Primary Nav Tabs */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

.nav-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.nav-tab-btn.active {
  color: var(--accent-cyan);
  background: var(--accent-cyan-bg);
  border: 1px solid var(--accent-cyan-border);
}

.tab-icon {
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-label {
  font-size: inherit;
  font-weight: inherit;
  line-height: 1;
}

.nav-tab-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: var(--accent-cyan-bg);
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan-border);
}

/* Header Utilities (Right) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.market-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-dot.open {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.status-dot.closed {
  background: var(--text-muted);
}

.header-clock {
  font-size: 0.82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  display: none; /* Shown on larger screens */
}

@media (min-width: 900px) {
  .header-clock {
    display: inline-block;
  }
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
  font-size: 1rem;
}

.icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
  border-color: var(--border-medium);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--accent-cyan);
  color: #0b0f19;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.25);
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  background: var(--accent-cyan-hover);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-active);
}

/* --- Level 2: Dynamic Sub-Navigation Bar --- */
.nav-secondary {
  min-height: var(--nav-height-secondary);
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  padding: 10px 0 12px 0 !important;
  gap: 8px 6px !important;
  width: 100% !important;
  overflow: visible !important;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}




/* Tag Chips */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tag-chip:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
  border-color: var(--border-medium);
}

.tag-chip.active {
  color: #0b0f19;
  background: var(--text-primary);
  border-color: var(--text-primary);
}

.tag-chip-count {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.2);
}

.tag-chip.active .tag-chip-count {
  background: rgba(0, 0, 0, 0.15);
  color: #0b0f19;
}

/* View Mode Toggles */
.view-mode-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-input);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.view-btn {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.view-btn:hover {
  color: var(--text-primary);
}

.view-btn.active {
  background: var(--bg-surface);
  color: var(--accent-cyan);
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------------------
   4. Main Content Canvas & Views
   -------------------------------------------------------------------------- */
.app-main {
  flex: 1;
  max-width: var(--container-max-width);
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.app-view {
  display: none;
  width: 100%;
  animation: fadeIn var(--transition-base) ease-in-out;
}

.app-view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   5. Home View (Bookmark Hub)
   -------------------------------------------------------------------------- */
.bookmark-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.search-container {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 540px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.95rem;
}

.search-input {
  width: 100%;
  padding: 10px 42px 10px 38px;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--accent-cyan-bg);
}

.search-shortcut-hint {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  pointer-events: none;
}

.bookmark-stats-pill {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Bookmark Section Categories */
.category-section {
  margin-bottom: 32px;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.category-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}

.category-count {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--text-muted);
}

/* Bookmark Grid Layout */
.bookmarks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Bookmark Card */
.bookmark-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  gap: 10px;
}

.bookmark-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.bookmark-card.pinned {
  border-color: var(--accent-amber-bg);
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(45, 35, 20, 0.4));
}

.card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-favicon-wrapper {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform var(--transition-fast);
}

.bookmark-card:hover .card-favicon-wrapper {
  transform: scale(1.05);
}

.card-favicon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.card-info {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  transition: color var(--transition-fast);
}

.bookmark-card:hover .card-title {
  color: var(--accent-cyan);
}

.card-footer {
  display: flex;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  gap: 8px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}

.card-tag-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
  z-index: 2;
}

.card-tag-pill:hover {
  background: var(--accent-cyan-bg);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan-border);
}

/* Bookmark List Layout */
.bookmarks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bookmarks-list .bookmark-card {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  gap: 16px;
}

.bookmarks-list .card-top {
  margin-bottom: 0;
  flex: 1;
  align-items: center;
}

.bookmarks-list .card-footer {
  border-top: none;
  padding-top: 0;
  flex-shrink: 0;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 0.9rem;
  max-width: 420px;
  margin: 0 auto 20px;
}

/* --------------------------------------------------------------------------
   6. Accounts View (Integrated Streamlit Dashboard - Seamless Single Scrollport)
   -------------------------------------------------------------------------- */
/* When Accounts view is active, eliminate outer page scrollbar completely */
body.view-accounts-active {
  overflow: hidden !important;
  height: 100vh !important;
  height: 100dvh !important;
}

body.view-accounts-active .app-main {
  padding: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  height: calc(100vh - var(--nav-height-primary)) !important;
  height: calc(100dvh - var(--nav-height-primary)) !important;
  overflow: hidden !important;
  flex: 1;
}

body.view-accounts-active #view-accounts {
  height: 100% !important;
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  animation: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.accounts-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  min-height: 0;
  background: #0b0f19;
  border-radius: 0;
  border: none;
  overflow: hidden;
  box-shadow: none;
  flex: 1;
}

.accounts-frame-wrapper {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  background: #0b0f19;
}

.accounts-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #0b0f19;
  display: block;
}

.iframe-loading-overlay {
  position: absolute;
  inset: 0;
  background: #0b0f19;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
  transition: opacity var(--transition-base);
}

.iframe-loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   7. Placeholder Views (Tools & Notes for Future Development)
   -------------------------------------------------------------------------- */
.placeholder-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 420px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  margin: 10px 0;
  box-shadow: var(--shadow-sm);
}

.placeholder-icon {
  font-size: 3.2rem;
  margin-bottom: 16px;
  opacity: 0.9;
}

.placeholder-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.placeholder-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  max-width: 480px;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   8.1 Multi-Dictionary View & Instant AI Pronunciation Preview
   -------------------------------------------------------------------------- */
.dict-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.dict-control-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dict-search-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dict-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.dict-search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: none;
}

.dict-search-box .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 1.05rem;
}

.dict-search-box .search-input {
  width: 100%;
  font-size: 1.02rem;
  padding: 11px 18px 11px 44px; /* Clean 44px left padding so search icon never overlaps typed letters */
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.dict-search-box .search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--accent-cyan-bg);
}

.dict-search-btn {
  padding: 11px 22px;
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
}

.dict-clear-btn {
  padding: 11px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

.dict-history-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dict-history-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.dict-history-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.dict-hist-pill {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dict-hist-pill:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan-border);
  background: var(--accent-cyan-bg);
}

/* Instant AI Pronunciation & Definition Card */
.dict-quick-card {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-fast);
}

.dict-quick-empty {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-secondary);
}

.dict-quick-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.spinner-small {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.dict-quick-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 12px;
}

.dict-word-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.dict-word-heading {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin: 0;
}

.dict-pronounce-badge {
  display: inline-flex;
  align-items: center;
}

.dict-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-cyan-bg);
  border: 1px solid var(--accent-cyan-border);
  color: var(--accent-cyan);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dict-audio-btn:hover {
  background: var(--accent-cyan);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.dict-audio-btn.playing {
  animation: pulse 1s infinite;
  background: var(--accent-cyan);
  color: #fff;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.dict-ipa-text {
  font-family: 'JetBrains Mono', monospace, sans-serif;
  font-size: 0.85rem;
}

.dict-quick-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dict-chinese-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-emerald-bg);
  border: 1px solid var(--accent-emerald-border);
  color: var(--accent-emerald);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
}

.dict-copy-btn {
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
}

.dict-def-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dict-def-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.dict-pos-tag {
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-medium);
  color: var(--accent-amber);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.dict-primary-def {
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.5;
  font-weight: 500;
}

.dict-example-text {
  font-size: 0.86rem;
  color: var(--text-muted);
  font-style: italic;
  padding-left: 8px;
  border-left: 2px solid var(--accent-cyan-border);
  margin-top: 2px;
}

.dict-extra-container {
  margin-top: 6px;
}

.dict-toggle-extra-btn {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  transition: color var(--transition-fast);
}

.dict-toggle-extra-btn:hover {
  text-decoration: underline;
}

.dict-extra-list {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

/* Dictionary Launchpad Chips */
.dict-launchpad {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dict-group-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dict-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.dict-group-hint {
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: none;
  color: var(--text-dim);
}

.dict-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dict-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-hover);
  color: var(--text-secondary);
}

.dict-chip:hover {
  background: var(--accent-cyan-bg);
  border-color: var(--accent-cyan-border);
  color: var(--accent-cyan);
  transform: translateY(-1px);
}

.dict-chip.embed.active {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.dict-chip.tab {
  border-style: dashed;
  background: var(--bg-input);
}

.dict-chip.tab:hover {
  border-style: solid;
}

.dict-chip-icon {
  font-size: 0.95rem;
}

/* Embedded Iframe Frame Section */
.dict-frame-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.dict-frame-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
  flex-wrap: wrap;
}

.dict-frame-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.dict-frame-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.dict-frame-url-label {
  font-size: 0.76rem;
  color: var(--text-dim);
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dict-frame-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dict-tool-btn {
  padding: 4px 10px;
  font-size: 0.78rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dict-frame-body {
  position: relative;
  width: 100%;
  height: 720px;
  background: #ffffff;
}

.dict-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* --------------------------------------------------------------------------
   9. Toast Notifications
   -------------------------------------------------------------------------- */

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp var(--transition-fast) ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   10. Responsive Breakpoints
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .header-inner {
    padding: 0 12px;
  }
  .app-main {
    padding: 14px 12px;
  }
  .brand-domain {
    display: none;
  }
  .nav-primary {
    gap: 8px;
  }
  .nav-tabs {
    gap: 3px;
  }
  .nav-tab-btn {
    padding: 6px 10px;
    font-size: 0.84rem;
    gap: 5px;
  }
  .bookmarks-grid {
    grid-template-columns: 1fr;
  }
  .bookmark-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-container {
    max-width: 100%;
  }
  .dict-frame-body {
    height: 520px;
  }
  .dict-quick-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .dict-quick-actions {
    width: 100%;
    justify-content: space-between;
  }
}

/* Compressed Navigation Bar for Mobile Phones */
@media (max-width: 580px) {
  .header-inner {
    padding: 0 8px;
  }
  .nav-primary {
    gap: 6px;
    height: 52px;
  }
  .brand-section {
    gap: 6px;
  }
  .brand-title-group {
    display: none; /* Hide brand text on phone to maximize navigation space */
  }
  .brand-logo {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }
  .nav-tabs {
    gap: 3px;
    flex-shrink: 1;
  }
  /* Inactive tabs collapse into compact icon buttons */
  .nav-tab-btn:not(.active) .tab-label {
    display: none;
  }
  .nav-tab-btn:not(.active) {
    padding: 6px 8px;
    border-radius: var(--radius-pill);
  }
  /* Active tab expands to show icon + label clearly */
  .nav-tab-btn.active {
    padding: 6px 11px;
    font-size: 0.82rem;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
  .header-actions {
    gap: 4px;
  }
  .nav-secondary {
    gap: 6px 4px !important;
    padding: 6px 0 8px 0 !important;
  }
  .tag-chip {
    padding: 4px 9px !important;
    font-size: 0.76rem !important;
  }
}

/* Extra Compact for Narrow Mobile Screens (< 380px) */
@media (max-width: 380px) {
  .nav-tab-btn .tab-label {
    display: none !important; /* Icon-only all tabs */
  }
  .nav-tab-btn {
    padding: 6px 7px !important;
    font-size: 1rem !important;
  }
  .icon-btn {
    width: 30px;
    height: 30px;
  }
}

