:root {
  /* Modern vibrant palette with depth */
  --bg-primary: #f0f4f8;
  --bg-secondary: #e1e8ed;
  --bg-canvas: #dce4ec;
  
  --surface: rgba(255, 255, 255, 0.95);
  --surface-elevated: rgba(255, 255, 255, 0.98);
  --surface-tinted: rgba(59, 130, 246, 0.04);

  --border: rgba(100, 116, 139, 0.12);
  --border-strong: rgba(100, 116, 139, 0.20);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;

  /* Primary: Vibrant Blue */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;

  /* Accent: Teal/Cyan */
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;

  /* Warm: Amber */
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-500: #f59e0b;
  --amber-600: #d97706;

  /* Success: Emerald */
  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-500: #10b981;
  --emerald-600: #059669;

  /* Accent gradients */
  --gradient-primary: linear-gradient(135deg, var(--blue-500) 0%, var(--blue-700) 100%);
  --gradient-accent: linear-gradient(135deg, var(--teal-500) 0%, var(--blue-500) 100%);
  --gradient-warm: linear-gradient(135deg, var(--amber-500) 0%, var(--amber-600) 100%);

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.10), 0 2px 4px -1px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.10), 0 4px 6px -2px rgba(15, 23, 42, 0.08);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 10px 10px -5px rgba(15, 23, 42, 0.08);

  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;

  --header-h: 92px;
  --tabs-h: 68px;
  --footer-h: 52px;
  --panel-w: 360px;

  --s-1: 6px;
  --s-2: 10px;
  --s-3: 14px;
  --s-4: 20px;
  --s-5: 32px;
}

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

html, body {
  height: 100%;
  margin: 0;
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.6;
}

body {
  background: 
    radial-gradient(ellipse 1200px 800px at 20% 10%, rgba(59, 130, 246, 0.06), transparent 50%),
    radial-gradient(ellipse 1000px 700px at 80% 90%, rgba(20, 184, 166, 0.05), transparent 50%),
    linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  overflow: hidden;
}

a { 
  color: inherit; 
  text-decoration: none;
  transition: all 200ms ease;
}

a.link { 
  color: var(--blue-600);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: border-color 200ms ease;
  font-weight: 500;
}

a.link:hover { 
  border-bottom-color: var(--blue-600);
}

.app {
  height: 100%;
  display: grid;
  grid-template-rows: var(--header-h) var(--tabs-h) 1fr var(--footer-h);
}

/* ========== HEADER ========== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface-elevated);
  backdrop-filter: blur(12px);
  position: relative;
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-accent);
  opacity: 0.4;
}

.brand {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--gradient-primary);
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.20), 0 3px 6px rgba(37, 99, 235, 0.12);
  font-size: 26px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.brand-mark::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 60%);
}

.brand-text { 
  min-width: 0;
}

.brand-title {
  font-weight: 800;
  letter-spacing: -0.6px;
  line-height: 1.1;
  font-size: 30px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--blue-600) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.brand-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* ========== TABS ========== */
.tabs {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px var(--s-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
}

.tab-btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  padding: 13px 26px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.2px;
  transition: all 220ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

.tab-btn::before {
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity 220ms ease;
}

.tab-btn:hover {
  transform: translateY(-2px);
  color: var(--text-primary);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.tab-btn.is-active {
  background: var(--gradient-primary);
  border-color: transparent;
    color: white !important;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.24), 0 3px 6px rgba(37, 99, 235, 0.16);
}

.tab-btn.is-active::before {
  opacity: 1;
  color: white !important;
}

.tab-btn.is-active:hover {
  transform: translateY(-2px);
  color: white !important;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.28), 0 4px 8px rgba(37, 99, 235, 0.18);
}

/* ========== STAGE & VIEWPORT ========== */
.stage {
  position: relative;
  overflow: hidden;
  background: var(--bg-canvas);
}

.viewport {
  position: absolute;
  inset: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  background: 
    radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.03), transparent 70%),
    linear-gradient(180deg, #e8eef5 0%, #dce4ec 100%);
  box-shadow: inset 0 2px 8px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(100, 116, 139, 0.08);
}

.tabcontent {
  position: absolute;
  inset: 0;
  display: none;
  background: transparent;
}

.tabcontent.is-active {
  display: block;
}

.panel {
  position: absolute;
  top: 24px;
  bottom: 24px;
  width: var(--panel-w);
  border-radius: var(--radius);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 10;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
}

.panel-left { left: 24px; }
.panel-right { right: 24px; max-height: max-content;}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 15px 5px 15px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.panel-title {
  font-weight: 700;
  letter-spacing: -0.4px;
  font-size: 17px;
  color: var(--text-primary);
}

.panel-body,
.control-panel {
  padding: 15px;
  overflow-y: auto;
  flex: 1;
}

.panel-body{
    padding: 20px;
}

.panel-actions { 
  display: flex; 
  gap: 8px; 
}

.btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 12px 22px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.2px;
  transition: all 220ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(20, 184, 166, 0.06) 100%);
  opacity: 0;
  transition: opacity 220ms ease;
}

.btn:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.btn:hover::before {
  opacity: 1;
}

.btn:active { 
  transform: translateY(0px);
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-primary);
  box-shadow: none;
}

.btn-ghost:hover {
  border-color: var(--blue-500);
  background: var(--blue-50);
  box-shadow: var(--shadow-sm);
  color: var(--blue-700);
}

.btn-primary {
  border-color: transparent;
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.24), 0 2px 4px rgba(37, 99, 235, 0.16);
}

.btn-primary:hover {
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.32), 0 4px 8px rgba(37, 99, 235, 0.20);
}

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

.btn-secondary:hover {
  border-color: var(--teal-500);
  background: var(--teal-50);
  color: var(--teal-700);
}

.btn-block {
  width: 100%;
  margin-top: 14px;
}

.icon-btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 9px 13px;
  transition: all 220ms cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 15px;
  font-weight: 700;
  min-width: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--blue-50);
  transform: translateY(-2px);
  border-color: var(--blue-500);
  color: var(--blue-700);
  box-shadow: var(--shadow-sm);
}

.icon-btn:active { 
  transform: translateY(0px); 
}

/* ========== CONTROLS ========== */
.control-group {
  padding: 18px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.02) 0%, rgba(20, 184, 166, 0.02) 100%);
  border: 1.5px solid var(--border);
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}

.control-group::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-accent);
  opacity: 0.4;
}

.control-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: -0.1px;
}

.help {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

.value-pill {
  font-size: 13px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--blue-500);
  background: var(--blue-50);
  color: var(--blue-700);
  min-width: 45px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.08);
}

.slider {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  accent-color: var(--blue-600);
  cursor: pointer;
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--border) 50%, transparent 100%);
  margin: 24px 0;
}

/* ========== DESCRIPTION ========== */
.description-text {
  margin: 0;
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 14px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.badge {
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--blue-500);
  background: var(--blue-50);
  color: var(--blue-700);
  font-weight: 600;
  letter-spacing: -0.1px;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.08);
}

.badge-muted {
  border-color: var(--teal-500);
  background: var(--teal-50);
  color: var(--teal-700);
}

/* ========== CORNER HINT ========== */
.corner-hint {
  position: absolute;
  left: 80%;
  bottom: 20px;
  z-index: 9;

  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: white;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);

  max-width: min(720px, calc(100vw - 48px));
  text-align: center;
}


.kbd {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--blue-50) 0%, var(--teal-50) 100%);
  border: 1.5px solid var(--border);
  margin-right: 8px;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.06);
}

/* ========== MODAL ========== */
.modal {
  width: min(580px, 92vw);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-xl);
  padding: 0;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
}

.modal-header {
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.92) 100%);
  position: relative;
}

.modal-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 28px;
  right: 28px;
  height: 2px;
  background: var(--gradient-accent);
  opacity: 0.3;
}

.modal-title {
  font-weight: 700;
  letter-spacing: -0.4px;
  font-size: 19px;
}

.modal-body { 
  padding: 28px; 
  color: var(--text-primary);
  line-height: 1.7;
}

.modal-footer { 
  padding: 24px 28px; 
  display: flex; 
  justify-content: flex-end; 
  gap: 12px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.5);
}

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--s-5);
  border-top: 1px solid var(--border);
  color: white;
  background: #2563eb;
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(12px);
  position: relative;
}

.footer::before {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  opacity: 1;
}

.panel-restore-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 11;
  display: none;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: all 220ms cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  font-size: 13px;
  backdrop-filter: blur(20px);
}

.panel-restore-btn:hover {
  transform: translateY(-50%) translateY(-3px);
  background: var(--blue-50);
  border-color: var(--blue-500);
  box-shadow: var(--shadow-xl);
  color: var(--blue-700);
}

.panel-restore-left { left: 24px; }
.panel-restore-right { right: 24px; }

/* ========== UTILITY CLASSES ========== */
.ui-hidden .panel,
.ui-hidden .corner-hint {
  display: none;
}

.ui-hidden .panel-restore-btn {
  display: none !important;
}

/* ========== FOCUS STYLES ========== */
:focus { 
  outline: none; 
}

:focus-visible {
  outline: 3px solid var(--blue-500);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ========== RESPONSIVE DESIGN ========== */
@media (prefers-reduced-motion: reduce) {
  * { 
    transition: none !important;
    animation: none !important;
  }
}

@media (max-width: 980px) {
  :root { 
    --panel-w: 340px;
    --s-5: 24px;
  }
  
  .brand-subtitle { 
    font-size: 13px;
  }
  
  .app-header, .tabs { 
    padding-left: 24px; 
    padding-right: 24px; 
  }
}

@media (max-width: 820px) {
  .panel-right { 
    display: none; 
  }
  
  :root { 
    --panel-w: 320px; 
  }
}

@media (max-width: 560px) {
  :root { 
    --header-h: 80px;
    --tabs-h: 64px;
    --s-5: 18px;
  }

  .brand-title {
    font-size: 24px;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
    font-size: 22px;
  }

  .header-actions { 
    gap: 8px; 
  }
  
  .btn { 
    padding: 11px 18px;
    font-size: 13px;
  }
  
  .tabs { 
    overflow-x: auto;
    gap: 10px;
  }

  .tab-btn {
    padding: 11px 20px;
    font-size: 13px;
  }
  
  .corner-hint { 
    display: none; 
  }

  .panel {
    width: calc(100vw - 32px);
    left: 16px !important;
    right: 16px !important;
  }

  .panel-left,
  .panel-right {
    left: 16px;
    right: 16px;
    width: auto;
  }
}