/* ── Reset & base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:   #2563eb;
  --accent2:  #1d4ed8;
  --bg:       #f8fafc;
  --white:    #ffffff;
  --border:   #e2e8f0;
  --text:     #1e293b;
  --subtle:   #64748b;
  --success:  #16a34a;
  --error:    #dc2626;
  --warning:  #d97706;
  --radius:   10px;
  --shadow:   0 1px 4px rgba(0,0,0,.08);
}

html { font-size: 16px; }
body {
  font-family: 'Segoe UI', system-ui, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Layout ─────────────────────────────────────────────────────────── */
.container { max-width: 1000px; margin: 0 auto; padding: 0 1.25rem; }
.page-content { flex: 1; padding: 2rem 1.25rem; }

/* ── Navbar ──────────────────────────────────────────────────────────── */
.navbar {
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.brand-icon { font-size: 1.4rem; }
.nav-links {
  list-style: none;
  display: flex;
  gap: .25rem;
}
.nav-links a {
  color: #bfdbfe;
  text-decoration: none;
  padding: .4rem .9rem;
  border-radius: 6px;
  font-size: .95rem;
  transition: background .15s, color .15s;
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(255,255,255,.18);
  color: #fff;
}

/* ── Footer ──────────────────────────────────────────────────────────── */
.footer {
  background: var(--border);
  color: var(--subtle);
  text-align: center;
  padding: .8rem;
  font-size: .85rem;
}

/* ── Alerts ──────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: .75rem;
  font-size: .95rem;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* ── Hero (index) ───────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 2.5rem 0 1.5rem;
}
.hero h1 { font-size: 2rem; font-weight: 800; color: var(--accent); }
.hero-sub { color: var(--subtle); margin-top: .5rem; font-size: 1.05rem; }

/* ── Feature cards ───────────────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .6rem;
  transition: box-shadow .18s, transform .18s;
  box-shadow: var(--shadow);
}
.card:hover { box-shadow: 0 6px 24px rgba(37,99,235,.12); transform: translateY(-3px); }
.card-icon { font-size: 2rem; }
.card h2   { font-size: 1.15rem; font-weight: 700; }
.card p    { color: var(--subtle); font-size: .92rem; flex: 1; }
.card-btn  {
  margin-top: .5rem;
  background: var(--accent);
  color: #fff;
  padding: .4rem 1rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 600;
}

/* ── Info / tip boxes ────────────────────────────────────────────────── */
.info-box, .tip-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  font-size: .92rem;
  color: #1e3a8a;
  margin-top: 1.5rem;
}
.tip-box { background: #fefce8; border-color: #fde68a; color: #78350f; }

/* ── Page header ─────────────────────────────────────────────────────── */
.page-header { margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.6rem; font-weight: 800; }
.page-header p  { color: var(--subtle); margin-top: .3rem; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.3rem;
  border-radius: 7px;
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-ghost  { background: var(--border); color: var(--text); }
.btn-ghost:hover  { background: #cbd5e1; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.form-actions {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* ── Dropzone ────────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--white);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone.drag-over {
  border-color: var(--accent);
  background: #eff6ff;
}
.drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem;
  gap: .4rem;
  text-align: center;
}
.drop-icon { font-size: 2.5rem; }
.drop-inner p { color: var(--subtle); font-size: .95rem; }
.link-label {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline;
}
.subtle { color: var(--subtle); font-size: .88rem; }
.selected-file {
  padding: .6rem 1rem;
  background: #eff6ff;
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-weight: 600;
  border-radius: 0 0 var(--radius) var(--radius);
}
.hidden { display: none !important; }

/* ── File list (merge) ───────────────────────────────────────────────── */
.file-list {
  margin-top: 1rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.file-list-header {
  display: flex;
  justify-content: space-between;
  padding: .6rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  font-weight: 600;
}
.file-list ul { list-style: none; }
.file-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .93rem;
}
.file-item:last-child { border-bottom: none; }
.file-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { color: var(--subtle); font-size: .85rem; min-width: 55px; text-align: left; }
.remove-btn {
  background: none;
  border: none;
  color: var(--subtle);
  cursor: pointer;
  font-size: 1rem;
  padding: .1rem .4rem;
  border-radius: 4px;
}
.remove-btn:hover { background: #fee2e2; color: var(--error); }

/* ── Form elements ───────────────────────────────────────────────────── */
.form-section { margin-bottom: 1.5rem; }
.form-label    { display: block; font-weight: 700; margin-bottom: .5rem; }
.form-label-sm { display: block; font-size: .9rem; color: var(--subtle); margin-bottom: .35rem; }
.form-input {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: .5rem .85rem;
  font-size: .95rem;
  width: 100%;
  max-width: 320px;
  background: var(--white);
}
.form-input.short { max-width: 100px; }
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #bfdbfe; }
.hint { color: var(--subtle); font-size: .85rem; margin-top: .3rem; }

/* ── Radio cards ─────────────────────────────────────────────────────── */
.radio-group { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.radio-card {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .8rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  transition: border-color .12s;
}
.radio-card:has(input:checked) { border-color: var(--accent); background: #eff6ff; }
.radio-card input { margin-top: .2rem; accent-color: var(--accent); }
.radio-content { display: flex; flex-direction: column; gap: .1rem; }
.radio-content strong { font-size: .97rem; }
.radio-content span   { font-size: .88rem; color: var(--subtle); }
.mode-options { margin: .5rem 0 .5rem 1.5rem; padding: .8rem 1rem; background: #f1f5f9; border-radius: 7px; }

/* ── Result box ──────────────────────────────────────────────────────── */
.result-box {
  background: var(--white);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.result-icon { font-size: 3rem; margin-bottom: .75rem; }
.result-box h2 { font-size: 1.5rem; font-weight: 800; color: var(--success); }
.result-box p  { color: var(--subtle); margin: .4rem 0 1.25rem; }
.download-list {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  justify-content: center;
  margin: .75rem 0;
}

/* ── Editor layout ───────────────────────────────────────────────────── */
.editor-layout {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}
.page-sidebar {
  width: 150px;
  flex-shrink: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.sidebar-header {
  padding: .6rem .8rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
  color: var(--subtle);
}
.page-nav { list-style: none; max-height: 500px; overflow-y: auto; }
.page-nav-item {
  padding: .5rem .8rem;
  font-size: .9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.page-nav-item:hover  { background: var(--bg); }
.page-nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }

.editor-main { flex: 1; }
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: .5rem .75rem;
  font-size: .88rem;
}
.toolbar-label { font-weight: 700; color: var(--accent); min-width: 110px; }
.toolbar-sep   { flex: 1; }
.btn-tool {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .25rem .65rem;
  font-size: .85rem;
  cursor: pointer;
  transition: background .12s;
}
.btn-tool:hover { background: var(--border); }
.tool-input {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .25rem .5rem;
  font-size: .85rem;
  width: 110px;
}
.text-editor {
  width: 100%;
  height: 400px;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: .85rem;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: .95rem;
  line-height: 1.6;
  resize: vertical;
  background: var(--white);
}
.text-editor:focus { outline: none; border-color: var(--accent); }
.editor-actions { margin-top: .75rem; display: flex; gap: .6rem; flex-wrap: wrap; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav-links a { padding: .3rem .6rem; font-size: .88rem; }
  .hero h1     { font-size: 1.5rem; }
  .editor-layout { flex-direction: column; }
  .page-sidebar  { width: 100%; }
  .page-nav      { display: flex; flex-wrap: wrap; max-height: none; }
  .page-nav-item { border-bottom: none; border-left: 1px solid var(--border); }
  .editor-toolbar { gap: .3rem; }
}
