:root {
  --bg-body: #f8fafc;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
}

html.dark {
  --bg-body: #0f172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --bg-card: #1e293b;
  --border-color: #334155;
  --input-bg: #1e293b;
  --input-border: #475569;
  --primary-color: #6366f1;
  --primary-hover: #818cf8;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-body) !important;
  color: var(--text-main) !important;
  font-family: 'Inter', sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
  transition: background 0.2s ease;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
.dark ::-webkit-scrollbar-thumb {
  background: #475569;
}
.dark ::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Form Elements */
input[type="number"],
input[type="text"],
input[type="date"],
select,
textarea {
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.2s ease;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.75rem;
  border-radius: 0.75rem;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.dark input[type="number"],
.dark input[type="text"],
.dark input[type="date"],
.dark select,
.dark textarea {
  background: #1e293b;
  border-color: #475569;
  color: #e2e8f0;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8 !important;
}

.dark input::placeholder,
.dark textarea::placeholder {
  color: #64748b !important;
}

input:focus,
select:focus,
textarea:focus {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  border-color: #4f46e5;
}

/* Mobile Menu Button */
.menu-toggle {
  display: none;
  padding: 0.75rem;
  border-radius: 1rem;
  border: 2px solid #e2e8f0;
  background: transparent;
  color: #64748b;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
}

.dark .menu-toggle {
  border-color: #334155;
  color: #94a3b8;
}

.menu-toggle:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: #4f46e5;
  color: #4f46e5;
}

.dark .menu-toggle:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: #6366f1;
  color: #6366f1;
}

.site-header {
  display: grid;
  grid-template-columns: auto 1fr auto; /* Logo - Nav - Toggle */
  align-items: center;
  gap: 2rem;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  padding: 1.5rem;
  border-radius: 1.5rem;
  border: 1px solid #e2e8f0;
  margin-bottom: 2rem;
  position: sticky;
  top: 1rem;
  z-index: 50;
}

.dark .site-header {
  background: rgba(30, 41, 59, 0.8);
  border-color: #334155;
}

/* Mobil görünüm için header düzenlemesi */
@media (max-width: 768px) {
  .site-header {
    grid-template-columns: auto 1fr auto auto; /* Logo - Spacer - Theme - Menu */
    gap: 0.75rem;
    padding: 1rem;
    position: relative;
  }
  
  .menu-toggle {
    display: flex;
  }
  
  .nav {
    position: absolute !important;
    top: calc(100% + 0.5rem) !important;
    left: 0 !important;
    right: 0 !important;
    flex-direction: column !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 1rem !important;
    padding: 0.5rem !important;
    gap: 0.25rem !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
    z-index: 1000 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  .dark .nav {
    background: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  
  .nav.hidden {
    display: none !important;
  }
  
  .nav-link {
    width: 100%;
    padding: 1rem;
    justify-content: center;
    font-size: 1rem;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-circle {
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.brand-logo {
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
  flex-shrink: 0;
}

/* Tailwind dark sınıfıyla birlikte görünürlük kontrolü için yardımcı sınıflar
   (Tailwind yüklü olduğu için inline/dark:hidden vs. çalışır, ekstra gerek yok) */

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand .brand-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.dark .brand h1 {
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.dark .brand .brand-title {
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand p {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 500;
}

.dark .brand p {
  color: #94a3b8;
}

.nav {
  display: flex;
  gap: 0.5rem;
  background: #f1f5f9;
  padding: 0.375rem;
  border-radius: 0.75rem;
  flex-wrap: wrap;
  justify-content: center; /* Menüyü ortala */
}

.dark .nav {
  background: rgba(71, 85, 105, 0.5);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-link:hover {
  background: rgba(99, 102, 241, 0.1);
  color: #4f46e5;
}

.nav-link.active {
  background: white;
  color: #4f46e5;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
}

.dark .nav-link {
  color: #94a3b8;
}

.dark .nav-link.active {
  background: #334155;
  color: #a78bfa;
}

.theme-toggle {
  padding: 0.75rem;
  border-radius: 1rem;
  border: 2px solid #e2e8f0;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  color: #475569;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.theme-toggle::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.theme-toggle i {
  position: relative;
  z-index: 1;
  transition: transform 0.3s ease;
}

.theme-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.15);
  border-color: #4f46e5;
}

.theme-toggle:hover::before {
  opacity: 0.1;
}

.theme-toggle:hover i {
  transform: rotate(20deg) scale(1.1);
  color: #4f46e5;
}

.dark .theme-toggle {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-color: #334155;
  color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dark .theme-toggle::before {
  background: linear-gradient(135deg, #6366f1 0%, #a78bfa 100%);
}

.dark .theme-toggle:hover {
  border-color: #a78bfa;
  box-shadow: 0 4px 16px rgba(167, 139, 250, 0.2);
}

.dark .theme-toggle:hover i {
  color: #a78bfa;
  transform: rotate(-20deg) scale(1.1);
}

/* Language Toggle Button */
.lang-toggle {
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(148, 163, 184, 0.1);
  color: #64748b;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  height: 3rem;
}

.lang-toggle:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: #4f46e5;
  transform: translateY(-1px);
}

.lang-toggle:active {
  transform: translateY(0);
}

.dark .lang-toggle {
  background: rgba(148, 163, 184, 0.05);
  border-color: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

.dark .lang-toggle:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
  color: #a78bfa;
}

.site-main {
  display: grid !important;
  grid-template-columns: 2fr 1fr !important;
  gap: 2rem !important;
  margin-bottom: 2rem !important;
}

.tools-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.side-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 1.5rem;
  padding: 2rem;
  transition: all 0.2s ease;
}

.dark .card {
  background: #1e293b;
  border-color: #334155;
}

.card.tool {
  display: none;
  animation: slideIn 0.3s ease-out;
}

.card.tool.active {
  display: block;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tool-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.dark .tool-header {
  border-color: #334155;
}

.tool-header h2 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #0f172a;
}

.dark .tool-header h2 {
  color: #f1f5f9;
}

.tool-header p {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.6;
}

.dark .tool-header p {
  color: #94a3b8;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 0;
}

.field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
}

.dark .field label {
  color: #cbd5e1;
}

.input-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.input-group .field select {
  font-size: 1rem;
  padding: 0.75rem;
}

.input-group.three-col {
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.input-group.three-col .field select {
  font-size: 0.938rem;
  padding: 0.688rem;
}

#unitCategory,
#kdvType {
  font-size: 1rem;
  padding: 0.75rem;
}

.input-group.full {
  grid-template-columns: 1fr;
}

.checkbox-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  cursor: pointer;
  background: white;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
}

.checkbox-group label:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.dark .checkbox-group label {
  background: #0f172a;
  border-color: #334155;
  color: #cbd5e1;
}

.dark .checkbox-group label:hover {
  background: #1e293b;
  border-color: #475569;
}

.checkbox-group input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: #4f46e5;
}

.primary-btn {
  width: 100%;
  padding: 1rem;
  border-radius: 0.875rem;
  border: none;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.primary-btn:active {
  transform: translateY(0);
}

.secondary-btn {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
  background: white;
  color: #64748b;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}

.dark .secondary-btn {
  background: #0f172a;
  border-color: #334155;
  color: #94a3b8;
}

.dark .secondary-btn:hover {
  background: #1e293b;
  border-color: #475569;
  color: #cbd5e1;
}

.icon-btn {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: #f1f5f9;
  color: #4f46e5;
}

.dark .icon-btn:hover {
  background: #1e293b;
  color: #a78bfa;
}

.swap-btn {
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  background: #f1f5f9;
  color: #4f46e5;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  width: 2.5rem;
  height: 2.5rem;
  align-self: center;
  margin-top: 1.5rem;
}

.swap-btn:hover {
  background: #e0e7ff;
  border-color: #4f46e5;
  transform: rotate(180deg);
}

.dark .swap-btn {
  background: #1e293b;
  border-color: #334155;
}

.btn-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.btn-row.two-col {
  grid-template-columns: 1fr 1fr;
  display: grid;
}

.btn-row.four-col {
  grid-template-columns: repeat(4, 1fr);
  display: grid;
  margin-top: 2rem;
}

.result-box {
  padding: 1.5rem;
  border-radius: 1rem;
  background: #eef2ff;
  border: 1px solid #e0e7ff;
  color: #312e81;
  font-weight: 600;
  font-size: 1.125rem;
  text-align: center;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.dark .result-box {
  background: #0f172a;
  border-color: #334155;
  color: #cbd5e1;
}

.result-box div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

textarea {
  resize: vertical;
  min-height: 150px;
  font-family: 'Monaco', 'Menlo', monospace;
}

.text-stats {
  padding: 1rem 0;
  border-top: 1px solid #e2e8f0;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.dark .text-stats {
  border-color: #334155;
  color: #94a3b8;
}

.info-card {
  border-radius: 1.5rem;
  padding: 2rem;
  border: none;
}

.info-card h3 {
  margin: 0 0 1rem;
  font-size: 1.125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-card p {
  margin: 0.75rem 0;
  line-height: 1.6;
  font-size: 0.938rem;
  color: inherit;
}

.info-card ul {
  margin: 1rem 0;
  padding-left: 1.5rem;
  list-style: none;
}

.info-card li {
  margin: 0.5rem 0;
  font-size: 0.938rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-card .note {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid;
  font-size: 0.75rem;
  opacity: 0.9;
}

.gradient-indigo {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
}

.gradient-amber {
  background: #fef3c7;
  color: #78350f;
}

.dark .gradient-amber {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

.dark .gradient-amber h3 {
  color: white;
}

.bottom-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.site-footer a:hover {
  color: var(--text-main) !important;
}

.bottom-card {
  border-radius: 1.5rem;
  border: 1px solid #e2e8f0;
  background: white;
  padding: 1.5rem;
}

.dark .bottom-card {
  background: #1e293b;
  border-color: #334155;
}

.bottom-card.favorites {
  background: linear-gradient(135deg, #fef3c7, #fef08a);
  border-color: #fcd34d;
}

.dark .bottom-card.favorites {
  background: #1e293b;
  border-color: #334155;
}

.bottom-card.history {
  background: linear-gradient(135deg, #cffafe, #a5f3fc);
  border-color: #67e8f9;
}

.dark .bottom-card.history {
  background: #1e293b;
  border-color: #334155;
}

.bottom-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid;
}

.bottom-card.favorites .bottom-header {
  border-color: #fcd34d;
}

.bottom-card.history .bottom-header {
  border-color: #67e8f9;
}

.dark .bottom-header {
  border-color: #334155;
}

.bottom-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bottom-card.favorites h3 {
  color: #b45309;
}

.bottom-card.history h3 {
  color: #0c4a6e;
}

.dark .bottom-header h3 {
  color: white;
}

.btn-clear {
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: #dc2626;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-clear:hover {
  background: rgba(220, 38, 38, 0.1);
}

.bottom-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  font-style: italic;
  font-size: 0.875rem;
}

.bottom-card.favorites .empty-state {
  color: #b45309;
}

.bottom-card.history .empty-state {
  color: #0c4a6e;
}

.dark .empty-state {
  color: #94a3b8;
}

.favorite-item,
.history-item {
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.favorite-item:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateX(4px);
}

.dark .favorite-item,
.dark .history-item {
  background: rgba(51, 65, 85, 0.5);
  border-color: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
}

.dark .favorite-item:hover {
  background: rgba(71, 85, 105, 0.7);
}

.site-footer {
  text-align: center;
  padding: 1rem 1.5rem;
  background: #f0f4f8;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  font-size: 0.875rem;
  color: #64748b;
}

.dark .site-footer {
  background: rgba(30, 41, 59, 0.5);
  border-color: #334155;
  color: #cbd5e1;
}

.site-footer p {
  margin: 0;
  color: inherit;
}

.site-footer a {
  color: var(--text-muted) !important;
}

.site-footer a:hover {
  color: var(--text-main) !important;
}

.site-footer strong {
  color: #4f46e5;
  font-weight: 600;
}

.dark .site-footer strong {
  color: #a78bfa;
}

@media (min-width: 1025px) {
  .site-main {
    display: grid !important;
    grid-template-columns: 2fr 1fr !important;
    gap: 2rem !important;
  }
}

@media (max-width: 1024px) {
  .site-main {
    grid-template-columns: 1fr !important;
  }

  .side-column {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .side-column .card {
    flex: 1 1 calc(50% - 0.75rem);
    min-width: 250px;
  }
}

@media (max-width: 768px) {
  .site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
  }

  .brand {
    flex: 1;
  }

  .menu-toggle {
    display: flex;
  }

  .nav {
    width: 100%;
    order: 10;
    flex-direction: column;
    /* hidden sınıfı kalktığında flex olacak, burada yönü dikey yapıyoruz */
  }

  .input-group {
    grid-template-columns: 1fr;
  }

  .input-group.three-col {
    grid-template-columns: 1fr;
  }

  .input-group.three-col .swap-btn {
    width: 100%;
  }

  .checkbox-group {
    grid-template-columns: 1fr;
  }

  .btn-row.four-col {
    grid-template-columns: repeat(2, 1fr);
  }

  .bottom-section {
    grid-template-columns: 1fr;
  }

  .side-column {
    flex-direction: column;
  }

  .side-column .card {
    flex: 1 1 auto;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 1rem;
  }

  .site-header {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 1rem;
  }

  .card {
    padding: 1.5rem;
    border-radius: 1rem;
  }

  .tool-header h2 {
    font-size: 1.25rem;
  }

  .btn-row.two-col {
    grid-template-columns: 1fr;
  }

  .btn-row.four-col {
    grid-template-columns: 1fr 1fr;
  }

  .bottom-content {
    max-height: 150px;
  }

  .field label {
    font-size: 0.8rem;
  }

  input[type="number"],
  input[type="text"],
  select,
  textarea {
    font-size: 16px;
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.hint {
  margin-top: 1rem;
  padding: 1rem;
  background: #f0f4f8;
  border-left: 3px solid #4f46e5;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #475569;
  line-height: 1.6;
}

.dark .hint {
  background: rgba(79, 70, 229, 0.1);
  color: #cbd5e1;
  border-left-color: #6366f1;
}

.hint i {
  margin-right: 0.5rem;
  color: #4f46e5;
}

.dark .hint i {
  color: #a78bfa;
}

.primary-btn:focus,
.secondary-btn:focus,
.nav-link:focus,
.theme-toggle:focus {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

@media (prefers-contrast: more) {
  .primary-btn {
    border: 2px solid #2d1b69;
  }

  .secondary-btn {
    border: 2px solid #475569;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* PATCH START - Theme & Color Fixes */
:root {
  --patch-bg: #f8fafc;
  --patch-card: #ffffff;
  --patch-text: #1e293b;
  --patch-text-muted: #64748b;
  --patch-border: #e2e8f0;
  --patch-input-bg: #ffffff;
}

html.dark {
  --patch-bg: #0f172a;
  --patch-card: #1e293b;
  --patch-text: #f8fafc;
  --patch-text-muted: #94a3b8;
  --patch-border: #334155;
  --patch-input-bg: #1e293b;
}

/* Force Theme Colors on Base Elements */
body {
  background-color: var(--patch-bg) !important;
  color: var(--patch-text) !important;
}

/* Card & Surface Fixes */
.card, 
.site-header, 
.site-footer, 
.bottom-card,
article,
section.card,
.bg-slate-100 {
  background-color: var(--patch-card) !important;
  border-color: var(--patch-border) !important;
  color: var(--patch-text) !important;
}

/* Input Fixes */
input, select, textarea {
  background-color: var(--patch-input-bg) !important;
  border-color: var(--patch-border) !important;
  color: var(--patch-text) !important;
}

input::placeholder, textarea::placeholder {
  color: var(--patch-text-muted) !important;
}

/* Text Visibility Fixes */
h1, h2, h3, h4, h5, h6, 
.brand-title, 
.text-slate-900, 
.text-slate-800 {
  color: var(--patch-text) !important;
}

p, li, span, div, 
.text-slate-700, 
.text-slate-600 {
  color: inherit;
}

/* Theme Toggle Button Fix */
.theme-toggle {
  border-color: var(--patch-border) !important;
  color: var(--patch-text) !important;
}
.theme-toggle:hover {
  background-color: var(--patch-border) !important;
}

/* Cookie Banner */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--patch-card);
  border-top: 1px solid var(--patch-border);
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  z-index: 100;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
  flex-wrap: wrap;
  text-align: center;
}
.cookie-banner p { margin: 0; font-size: 0.875rem; color: var(--patch-text); }
.cookie-banner a { color: var(--primary-color); text-decoration: underline; }
