:root {
  --bg: #0a0e1a;
  --panel: #1a1f2e;
  --secondary: #2a3142;
  --muted: #64748b;
  --text: #f1f5f9;
  --brand: #22c55e;
  --brand-hover: #16a34a;
  --border: #475569;
  --error: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 16px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app { max-width: 900px; margin: 16px auto; padding: 0 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.grid { display: grid; gap: 12px; }
@media (min-width: 720px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } }

.row { display: grid; grid-template-columns: 160px 1fr; gap: 10px; align-items: center; }
.row + .row { margin-top: 10px; }
.row label { color: var(--muted); }

input[type="number"], input[type="text"], input[type="email"], input[type="tel"], select, textarea {
  width: 100%;
  background: var(--secondary);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 16px 14px;
  font-size: 16px; /* Prevents zoom on iOS */
  min-height: 48px; /* Touch-friendly minimum */
  transition: all 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: var(--shadow-sm);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2), var(--shadow-sm);
}

textarea {
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
}
input::placeholder { color: #8aa; }

button, .btn {
  background: var(--brand);
  color: #0a1f16;
  border: none;
  font-weight: 700;
  padding: 16px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  min-height: 48px;
  min-width: 48px;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

button:hover, .btn:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

button:active, .btn:active {
  transform: translateY(0px) scale(0.98);
  transition: all 0.1s ease;
}

button.secondary { 
  background: transparent; 
  color: var(--text); 
  border: 2px solid var(--border);
  box-shadow: none;
}

button.secondary:hover {
  border-color: var(--brand);
  background: rgba(34, 197, 94, 0.05);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Copy buttons */
.copy-btn {
  padding: 8px 12px;
  font-size: 14px;
  min-height: 36px;
  background: rgba(34, 197, 94, 0.1);
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.copy-btn:hover {
  background: var(--brand);
  color: #0a1f16;
}

.muted { color: var(--muted); }
.result { font-size: 1.1rem; font-weight: 600; }
.error { color: var(--error); }

.tool-list { display:grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tool-card { display:block; text-decoration:none; color:inherit; }
.tool-card h3 { margin: 8px 0 6px; }
.tool-card p { margin: 0; color: var(--muted); }

.calc {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.calc-display {
  grid-column: 1 / -1;
  padding: 12px;
  text-align: right;
  font-size: 1.4rem;
  background: rgba(15,23,42,0.6);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
}
.calc button { padding: 12px; font-size: 1rem; }
.calc .span-2 { grid-column: span 2; }
.calc .op { background: #3b82f6; color: #0f172a; box-shadow: var(--shadow-sm); }
.calc .eq { background: var(--brand); color: #0a1f16; box-shadow: var(--shadow-sm); }

.site-footer {
  display:flex; justify-content: space-between; align-items:center; gap: 12px;
  padding: 16px;
  color: var(--muted);
}

/* Mobile-first preset buttons */
.preset-section {
  margin: 16px 0;
  padding: 16px;
  background: rgba(34, 197, 94, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(34, 197, 94, 0.1);
  box-shadow: var(--shadow-sm);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.preset-btn {
  padding: 12px 8px;
  font-size: 14px;
  background: rgba(34, 197, 94, 0.1);
  color: var(--brand);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 6px;
  text-align: center;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  box-shadow: var(--shadow-sm);
}

.preset-btn:hover, .preset-btn:active {
  background: rgba(34, 197, 94, 0.2);
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
}

.preset-btn .preset-title {
  font-weight: 600;
  color: var(--text);
}

.preset-btn .preset-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Result with copy button */
.result-with-copy {
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-with-copy .result {
  flex: 1;
  font-family: monospace;
}

/* Copy status animation */
.copy-status {
  font-size: 12px;
  color: var(--brand);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.copy-status.show {
  opacity: 1;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
  .app {
    padding: 0 12px;
    margin: 16px auto;
  }
  
  .card {
    padding: 20px 16px;
  }
  
  .row {
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: left;
  }
  
  .row label {
    font-size: 14px;
    margin-bottom: 4px;
  }
  
  .grid.cols-2 {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .preset-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .tool-list {
    grid-template-columns: 1fr;
  }
}

/* Touch feedback */
@media (hover: none) {
  button:hover, .btn:hover {
    transform: none;
    box-shadow: none;
  }
  
  button:active, .btn:active {
    transform: scale(0.95);
    opacity: 0.8;
  }
}
