@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --primary: #e63946;
  --primary-dark: #c1121f;
  --primary-light: #ff6b6b;
  --secondary: #457b9d;
  --bg: #ffffff;
  --bg-gray: #f8f9fa;
  --bg-card: #ffffff;
  --text: #1d3557;
  --text-muted: #6c757d;
  --border: #dee2e6;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 8px 30px rgba(0,0,0,0.14);
  --radius: 12px;
  --header-h: 64px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ─── HEADER ─── */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
}

.header-inner {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--primary);
}

.logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 1.1rem;
}

.nav { display: flex; align-items: center; gap: 6px; }

.nav a {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all .2s;
}

.nav a:hover, .nav a.active {
  background: #fff0f0;
  color: var(--primary);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 24px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: .3s;
}

.mobile-nav {
  display: none;
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  flex-direction: column;
  gap: 4px;
  z-index: 99;
}

.mobile-nav.open { display: flex; }
.mobile-nav a {
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text);
  transition: .2s;
}
.mobile-nav a:hover { background: #fff0f0; color: var(--primary); }

/* ─── MAIN / HERO ─── */
.main { margin-top: var(--header-h); }

.hero {
  background: linear-gradient(135deg, #fff0f0 0%, #fff 60%, #f0f6ff 100%);
  padding: 70px 20px 50px;
  text-align: center;
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
  margin-bottom: 14px;
}

.hero h1 span { color: var(--primary); }

.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 580px;
  margin: 0 auto 30px;
}

/* ─── AD BANNER ─── */
.ad-banner {
  max-width: 970px;
  margin: 20px auto;
  padding: 0 20px;
  text-align: center;
}

.ad-label {
  font-size: 0.7rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

/* ─── TOOLS GRID ─── */
.section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 50px 20px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.section-sub {
  color: var(--text-muted);
  margin-bottom: 30px;
  font-size: 0.95rem;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}

.tool-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 18px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .25s;
  text-decoration: none;
  display: block;
}

.tool-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.tool-card-icon {
  width: 54px; height: 54px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  font-size: 1.7rem;
}

.tool-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.tool-card p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ─── TOOL PAGE ─── */
.tool-hero {
  background: linear-gradient(135deg, #fff0f0 0%, #fff 100%);
  padding: 50px 20px 40px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.tool-hero-icon {
  width: 72px; height: 72px;
  border-radius: 18px;
  margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem;
}

.tool-hero h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.tool-hero p {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 480px;
  margin: 0 auto;
}

.tool-body {
  max-width: 860px;
  margin: 40px auto;
  padding: 0 20px 60px;
}

/* ─── UPLOAD ZONE ─── */
.upload-zone {
  border: 2.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 50px 30px;
  text-align: center;
  background: var(--bg-gray);
  cursor: pointer;
  transition: all .25s;
  position: relative;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: #fff5f5;
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-zone-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  display: block;
  line-height: 1;
}

.upload-zone h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.btn-select {
  display: inline-block;
  margin-top: 16px;
  padding: 11px 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: .2s;
}

.btn-select:hover { background: var(--primary-dark); }

/* ─── OPTIONS PANEL ─── */
.options-panel {
  background: var(--bg-gray);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-top: 24px;
}

.options-panel h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text);
}

.options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.opt-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 130px;
}

.opt-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.opt-group select,
.opt-group input[type="number"],
.opt-group input[type="text"],
.opt-group input[type="range"] {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.92rem;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: .2s;
  width: 100%;
}

.opt-group select:focus,
.opt-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230,57,70,.1);
}

/* ─── PREVIEW ─── */
.preview-section {
  margin-top: 24px;
  display: none;
}

.preview-section.visible { display: block; }

.preview-box {
  background: var(--bg-gray);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.preview-box img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.preview-info {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.badge {
  background: #edf2ff;
  color: #364fc7;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-convert {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: .2s;
}

.btn-convert:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-convert:disabled { background: #ccc; cursor: not-allowed; transform: none; }

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 26px;
  background: #2d6a4f;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: .2s;
  text-decoration: none;
}

.btn-download:hover { background: #1b4332; }

/* ─── PROGRESS ─── */
.progress-wrap {
  margin-top: 20px;
  display: none;
}

.progress-wrap.visible { display: block; }

.progress-bar-outer {
  background: var(--border);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}

.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 99px;
  transition: width .3s;
  width: 0%;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
}

/* ─── RESULT AREA ─── */
.result-area {
  margin-top: 20px;
  background: var(--bg-gray);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  display: none;
}

.result-area.visible { display: block; }

.result-success {
  font-size: 3rem;
  margin-bottom: 10px;
}

.result-area h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2d6a4f;
  margin-bottom: 6px;
}

/* ─── COLOR CONVERTER ─── */
.color-preview {
  width: 100%;
  height: 180px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  border: 1px solid var(--border);
  transition: background .2s;
}

.color-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.color-field {
  background: var(--bg-gray);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.color-field-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.color-field input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  background: #fff;
  color: var(--text);
  outline: none;
  margin-bottom: 6px;
}

.color-field input:focus { border-color: var(--primary); }

.btn-copy {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: .2s;
}

.btn-copy:hover { border-color: var(--primary); color: var(--primary); }
.btn-copy.copied { border-color: #2d6a4f; color: #2d6a4f; }

.color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.color-picker-wrap label { font-weight: 600; font-size: 0.9rem; }

input[type="color"] {
  width: 50px;
  height: 40px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}

/* ─── UNITS ─── */
.unit-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.unit-tab {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
  color: var(--text-muted);
}

.unit-tab:hover { border-color: var(--primary); color: var(--primary); }
.unit-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.unit-input-row {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  align-items: flex-end;
}

.unit-input-row input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: .2s;
}

.unit-input-row input:focus { border-color: var(--primary); }

.unit-input-row select {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  background: #fff;
  cursor: pointer;
}

.unit-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.unit-result-item {
  background: var(--bg-gray);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.unit-result-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  word-break: break-all;
}

.unit-result-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ─── TEXT TOOLS ─── */
.text-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.text-tab {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
  color: var(--text-muted);
}

.text-tab:hover { border-color: var(--primary); color: var(--primary); }
.text-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.text-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.text-editor-col h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.text-editor textarea {
  width: 100%;
  height: 280px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  resize: vertical;
  outline: none;
  color: var(--text);
  transition: .2s;
}

.text-editor textarea:focus { border-color: var(--primary); }

.text-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 7px 14px;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: .2s;
}

.btn-sm:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-sm.primary:hover { background: var(--primary-dark); }

/* ─── NUMBER CONVERTER ─── */
.number-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.number-box {
  background: var(--bg-gray);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.number-box-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.number-box input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: .2s;
}

.number-box input:focus { border-color: var(--primary); }

/* ─── TOAST ─── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1d3557;
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 1000;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ─── FOOTER ─── */
.footer {
  background: #1d3557;
  color: rgba(255,255,255,.7);
  padding: 40px 20px;
  text-align: center;
  font-size: 0.85rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin-bottom: 16px;
}

.footer-links a {
  color: rgba(255,255,255,.7);
  transition: .2s;
}

.footer-links a:hover { color: #fff; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .nav { display: none; }
  .hamburger { display: flex; }

  .hero h1 { font-size: 2rem; }

  .tools-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }

  .color-inputs { grid-template-columns: 1fr; }

  .text-editor { grid-template-columns: 1fr; }

  .number-grid { grid-template-columns: 1fr; }

  .options-row { flex-direction: column; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.65rem; }
  .tool-hero h1 { font-size: 1.5rem; }
  .tools-grid { grid-template-columns: 1fr 1fr; }
}
