:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Dark theme defaults */
  --bg-primary: #0e1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-input: #0d1117;
  --border-color: #30363d;
  --border-focus: #58a6ff;
  
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;

  --accent: #238636;
  --accent-hover: #2ea043;
  --accent-blue: #388bfd;
  --accent-blue-hover: #58a6ff;

  --badge-bg: rgba(35, 134, 54, 0.15);
  --badge-text: #3fb950;
  --danger-color: #f85149;
  
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.2);
}

body.light-theme {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #eaeef2;
  --bg-input: #ffffff;
  --border-color: #d0d7de;
  --border-focus: #0969da;

  --text-primary: #1f2328;
  --text-secondary: #656d76;
  --text-muted: #8c959f;

  --accent: #1f883d;
  --accent-hover: #1a7f37;
  --accent-blue: #0969da;
  --accent-blue-hover: #218bff;

  --badge-bg: #dafbe1;
  --badge-text: #1a7f37;
  --danger-color: #cf222e;

  --shadow-sm: 0 1px 3px rgba(31,35,40,0.08);
  --shadow-md: 0 4px 6px -1px rgba(31,35,40,0.12);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Header */
.app-header {
  height: 60px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.15rem;
}

.logo svg {
  color: var(--accent-blue);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.badge-privacy {
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 1px solid rgba(63, 185, 80, 0.2);
}

.badge .dot {
  width: 6px;
  height: 6px;
  background-color: currentColor;
  border-radius: 50%;
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Layout */
.layout {
  display: flex;
  flex: 1;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 12px 10px 12px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  width: 100%;
}

.nav-item:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
  border-left: 3px solid var(--accent-blue);
}

.nav-icon {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  width: 20px;
  text-align: center;
  color: var(--accent-blue);
}

.sidebar-footer {
  padding: 16px 12px 0 12px;
  border-top: 1px solid var(--border-color);
}

.privacy-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 32px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.2s ease-out;
}

.tab-panel.active {
  display: block;
}

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

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.panel-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.panel-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

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

.btn-secondary:hover {
  border-color: var(--text-secondary);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-outline:hover {
  background-color: var(--bg-tertiary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

.btn-sm {
  padding: 4px 8px;
  font-size: 0.75rem;
}

/* Editor Grid */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-height: 440px;
}

.editor-pane {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.pane-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background-color: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pane-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-indicator {
  font-size: 0.75rem;
  font-weight: 500;
}

.status-indicator.valid {
  color: var(--badge-text);
}

.status-indicator.invalid {
  color: var(--danger-color);
}

.editor-pane textarea {
  flex: 1;
  padding: 14px;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
}

.editor-pane textarea:focus {
  outline: none;
}

/* Form inputs */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

input[type="text"], input[type="number"], textarea {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

input[type="text"]:focus, input[type="number"]:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

.code-font {
  font-family: var(--font-mono) !important;
  font-size: 0.85rem !important;
}

/* Hash generator */
.hashes-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hash-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
}

.hash-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Password Generator */
.generator-box {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.password-display-wrapper {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.password-field {
  flex: 1;
  font-size: 1.15rem !important;
  font-weight: 600;
  letter-spacing: 0.05em;
  background-color: var(--bg-input) !important;
}

.strength-meter-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.meter-bar {
  flex: 1;
  height: 6px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background-color: var(--badge-text);
  transition: width 0.3s ease, background-color 0.3s ease;
}

.strength-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--badge-text);
  min-width: 80px;
}

.generator-controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider {
  width: 100%;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

/* Sub tool cards */
.sub-tool-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.sub-tool-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.inline-tool-row {
  display: flex;
  gap: 10px;
}

.timestamp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.ts-result-box {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Text Inspector Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat-box {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.stat-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent-blue);
  font-family: var(--font-mono);
}

.stat-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: 4px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  padding: 20px 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: auto;
}

.footer-muted {
  margin-top: 4px;
  font-size: 0.75rem;
}

.hidden {
  display: none !important;
}

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }

/* Responsive adjustments */
@media (max-width: 850px) {
  .layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 12px;
  }
  .nav-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .nav-item {
    white-space: nowrap;
    padding: 6px 12px;
  }
  .sidebar-footer {
    display: none;
  }
  .editor-grid, .timestamp-grid {
    grid-template-columns: 1fr;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .badge-privacy {
    display: none;
  }
}
