:root {
  /* AltaySec Premium Dark Palette */
  --bg-main: #070709;
  --bg-sidebar: #0e0e12;
  --bg-panel: rgba(20, 20, 26, 0.65);
  --bg-input: #15151b;
  --bg-hover: rgba(218, 41, 46, 0.1);
  
  --text-main: #f1f1f4;
  --text-muted: #8b8b99;
  
  --accent-red: #da292e;
  --accent-red-hover: #f93c41;
  --accent-glow: rgba(218, 41, 46, 0.3);
  
  --border-color: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-focus: rgba(218, 41, 46, 0.5);

  --sidebar-w: 280px;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(218, 41, 46, 0.03), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(218, 41, 46, 0.04), transparent 25%);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  font-smooth: always;
  -webkit-font-smoothing: antialiased;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

.app-layout {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, transparent 100%);
}

.brand-logo-img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px var(--accent-glow));
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #fff, #b1b1c5);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text .badge {
  font-size: 10px;
  color: var(--accent-red);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.search-box {
  margin: 20px 16px 12px;
  position: relative;
}

.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  transition: color 0.3s;
}

.search-box input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 12px 12px 42px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s;
  outline: none;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.search-box input:focus {
  border-color: var(--accent-red);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2), 0 0 0 3px rgba(218, 41, 46, 0.15);
}
.search-box input:focus + svg {
  color: var(--accent-red);
}

.tool-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 24px;
}

/* Scrollbar customization */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

.nav-group {
  margin-bottom: 24px;
}

.nav-group-title {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 1.2px;
  margin: 12px 14px 8px;
  text-transform: uppercase;
  opacity: 0.8;
}

.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 4px;
  position: relative;
  overflow: hidden;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  transform: translateX(4px);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(218, 41, 46, 0.15), rgba(218, 41, 46, 0.05));
  border-color: rgba(218, 41, 46, 0.3);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent-red);
}

.sidebar-footer {
  padding: 16px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border-color);
  background: var(--bg-sidebar);
}

/* Workspace main area */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
}

.workspace-header {
  padding: 32px 40px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(14, 14, 18, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 5;
}

.tool-info h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
  color: #fff;
}

.tool-info p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  max-width: 800px;
}

/* Custom Settings Drop */
.custom-settings {
  padding: 20px 40px;
  background: rgba(20, 20, 25, 0.6);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 20px;
  align-items: flex-end;
  flex-wrap: wrap;
  backdrop-filter: blur(10px);
}
.custom-settings.hidden {
  display: none;
}

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

.setting-group label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

.setting-group input, 
.setting-group select {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Fira Code', monospace;
  outline: none;
  min-width: 180px;
  transition: all 0.2s;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}
.setting-group input:focus, 
.setting-group select:focus {
  border-color: var(--accent-red);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2), 0 0 0 3px rgba(218, 41, 46, 0.15);
}

/* Core Editor Panels */
.panels-container {
  flex: 1;
  display: flex;
  padding: 24px 40px;
  gap: 20px;
  position: relative;
  overflow: hidden;
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--accent-red), 0 0 20px rgba(218, 41, 46, 0.15);
  transform: translateY(-2px);
}

.panel-header {
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: rgba(14, 14, 18, 0.5);
}

.panel-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.panel:focus-within .panel-title {
  color: #fff;
}

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

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.icon-btn:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--border-color);
  color: #fff;
}

.panel-body {
  flex: 1;
  position: relative;
}

.panel-body textarea {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  color: #fff;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.6;
  padding: 20px;
  resize: none;
  outline: none;
}

.panel-body textarea::placeholder {
  color: #4a4a58;
  font-family: 'Inter', sans-serif;
  font-style: italic;
  font-weight: 400;
}

.panel-footer {
  padding: 10px 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  text-align: right;
  background: rgba(14, 14, 18, 0.5);
}

/* Arrow divider */
.panel-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.1);
  transition: color 0.3s;
}
.panels-container:focus-within .panel-divider {
  color: var(--border-focus);
}

/* Error states for output */
.error-text {
  color: var(--accent-red) !important;
}

/* History Sidebar */
.history-sidebar {
  width: 260px;
  background: rgba(14, 14, 18, 0.95);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow: -4px 0 24px rgba(0,0,0,0.4);
}
.history-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.history-header h3 {
  font-size: 14px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.history-empty {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 30px;
  font-style: italic;
}
.history-item {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.history-item:hover {
  border-color: var(--accent-red);
  background: rgba(218, 41, 46, 0.05);
}
.hist-tool {
  font-size: 10px;
  color: var(--accent-red);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.hist-preview {
  font-size: 11px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Fira Code', monospace;
}

/* Drag and Drop Hover */
.drag-over {
  border: 2px dashed var(--accent-red) !important;
  background: rgba(218, 41, 46, 0.05) !important;
}

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

.toast {
  background: rgba(20, 20, 26, 0.95);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-red);
  border-radius: 8px;
  padding: 14px 20px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 340px;
}

.toast.success {
  border-left-color: #22c55e;
}

.toast.error {
  border-left-color: #ef4444;
}

.toast.fade-out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5000;
  opacity: 0;
  display: none;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  display: block;
  pointer-events: auto;
}

.mobile-menu-state {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mobile-top-bar {
  display: none;
  align-items: center;
  justify-content: flex-start;
  padding: 0 12px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 6000;
  height: 60px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.mobile-menu-fab {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  background: rgba(14, 14, 18, 0.96);
  color: #fff;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  cursor: pointer;
  z-index: 12000;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

.mobile-menu-fab svg {
  pointer-events: none;
}

.mobile-brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #fff, var(--accent-red));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

@media (max-width: 1024px) {
  .app-layout {
    height: auto;
    min-height: 100vh;
  }
  .history-sidebar { display: none; }
  .panels-container {
    flex-direction: column;
    padding: 20px !important;
    height: auto !important;
    overflow: visible !important;
  }
}

@media (max-width: 768px) {
  body:has(.mobile-menu-state:checked) {
    overflow: hidden !important;
  }
  * {
    max-width: 100vw;
    box-sizing: border-box;
  }
  body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    width: 100%;
  }
  .app-layout {
    display: block;
    width: 100%;
  }
  .mobile-top-bar {
    display: flex;
    padding-left: max(76px, calc(env(safe-area-inset-left) + 76px));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-top: env(safe-area-inset-top);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(60px + env(safe-area-inset-top));
    pointer-events: auto;
  }
  .mobile-menu-fab {
    display: flex;
    top: calc(env(safe-area-inset-top) + 8px);
    left: max(12px, calc(env(safe-area-inset-left) + 12px));
  }
  .mobile-menu-state:checked ~ .sidebar-backdrop {
    opacity: 1;
    display: block;
    pointer-events: auto;
  }
  .mobile-menu-state:checked ~ .mobile-menu-fab {
    background: rgba(218, 41, 46, 0.18);
    border-color: rgba(218, 41, 46, 0.45);
  }
  .mobile-menu-state:checked ~ .sidebar {
    left: 0 !important;
  }
  .sidebar {
    position: fixed;
    left: -105%;
    top: 0;
    bottom: 0;
    width: 85%;
    max-width: 300px;
    height: 100vh;
    z-index: 7000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-top: env(safe-area-inset-top);
  }
  .sidebar.open {
    left: 0;
  }
  .search-box {
    margin: 16px;
  }
  .search-box input {
    min-height: 48px;
    font-size: 16px;
  }
  .tool-nav {
    padding-bottom: 120px;
  }
  .nav-item {
    min-height: 44px;
    padding: 12px 14px;
  }
  .workspace {
    width: 100%;
    height: auto;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    padding-top: calc(60px + env(safe-area-inset-top));
  }
  .workspace-header {
    padding: 30px 20px 0;
  }
  .tool-info h2 {
    font-size: 22px;
  }
  .tool-info p {
    font-size: 15px;
  }
  .panels-container {
    padding: 10px 15px 40px !important;
    gap: 15px;
    width: 100%;
  }
  .panel {
    width: 100%;
    margin-bottom: 10px;
  }
  .panel-divider {
    transform: rotate(90deg);
    padding: 4px 0;
  }
  .panel-header,
  .panel-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .panel-actions {
    gap: 10px;
  }
  .icon-btn {
    width: 40px;
    height: 40px;
  }
  .panel-body {
    min-height: clamp(280px, 42vh, 420px);
  }
  .panel-body textarea {
    position: relative;
    min-height: clamp(280px, 42vh, 420px);
    height: 100%;
    font-size: 16px !important; /* iOS Zoom Fix */
    line-height: 1.5;
    padding: 18px 16px;
  }
  #outputBox {
    min-height: clamp(240px, 36vh, 360px);
  }
  .custom-settings {
    padding: 15px 20px;
    gap: 14px;
  }
  .setting-group {
    width: 100%;
  }
  .setting-group input,
  .setting-group select {
    font-size: 16px !important; /* Meta fix */
    min-width: 100%;
    width: 100%;
    min-height: 48px;
  }
}
