@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg: #0e1117;
  --surface: #161b27;
  --card: #1c2333;
  --border: #2a3348;
  --accent: #6fa3ff;
  --accent2: #e2934f;
  --success: #3ed389;
  --danger: #e4685a;
  --warn: #e2a23f;
  --purple: #8b93e0;
  --text: #d0d8f0;
  --muted: #5a6480;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans', sans-serif;
}

body.light {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --card: #eef1f8;
  --border: #d0d8e8;
  --text: #1a2340;
  --muted: #7a8aaa;
}

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

body {
  visibility: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.ready { visibility: visible; }

/* ── Header ─────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo { display: flex; align-items: center; gap: 12px; }

.logo-icon {
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  background: rgba(111, 163, 255, .12);
  color: var(--accent);
}

.logo-text { font-family: var(--sans); font-weight: 600; font-size: 15px; letter-spacing: .5px; }
.logo-sub { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 1px; }

.hbadges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.badge {
  padding: 3px 10px; border-radius: 100px; font-size: 11px;
  font-family: var(--sans); font-weight: 600; white-space: nowrap;
}
.bo { background: rgba(111, 163, 255,.15); color: var(--accent); border: 1px solid rgba(111, 163, 255,.3); }
.bb { background: rgba(226, 147, 79,.12); color: var(--accent2); border: 1px solid rgba(226, 147, 79,.25); }
.bg { background: rgba(62, 211, 137,.12); color: var(--success); border: 1px solid rgba(62, 211, 137,.3); }

#themeToggle {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 6px 10px; border-radius: 7px; cursor: pointer; font-size: 15px; line-height: 1;
  transition: background-color .15s, border-color .15s, color .15s, transform .15s, box-shadow .15s, opacity .15s;
}
#themeToggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── Main ───────────────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.card-title { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px; border-radius: 7px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; font-family: var(--sans);
  transition: background-color .15s, border-color .15s, color .15s, transform .15s, box-shadow .15s, opacity .15s; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #111; }
.btn-primary:hover { background: #8ab4ff; }
.btn-primary.copied { background: var(--success); color: #111; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #3a4560; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Form controls ──────────────────────────────────────────────── */
.fc {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 8px 10px; font-size: 13px; font-family: var(--sans);
  transition: border-color .15s; width: 100%;
}
.fc:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(111, 163, 255,.12); }

.fg-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted); margin-bottom: 6px; display: block;
}

/* ── Text Flip panels ───────────────────────────────────────────── */
.flip-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: start;
}

.flip-panel { display: flex; flex-direction: column; }

.flip-textarea {
  height: 260px;
  font-size: 15px;
  line-height: 1.7;
  resize: vertical;
  direction: rtl;
}

.output-box {
  height: 260px;
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  color: var(--accent2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  direction: rtl;
  cursor: pointer;
  user-select: all;
  transition: background .2s, border-color .2s;
}
.output-box:hover { border-color: var(--accent2); }
.output-box.flash { background: rgba(226, 147, 79,.08); border-color: var(--accent2); }

.flip-arrow-col {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: calc(11px + 1em + 6px); /* align with textarea top, below the label */
  height: 260px;
}

.flip-swap-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; transition: background-color .2s, border-color .2s, color .2s, transform .2s, box-shadow .2s, opacity .2s;
}
.flip-swap-btn:hover { border-color: var(--accent); background: rgba(111, 163, 255,.1); transform: scale(1.05); }
.flip-swap-btn svg { width: 20px; height: 20px; transition: transform .35s cubic-bezier(0.34,1.56,0.64,1); }
.flip-swap-btn:hover svg { transform: rotate(180deg); }

.flip-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

@media (max-width: 640px) {
  .flip-grid { grid-template-columns: 1fr; }
  .flip-arrow-col { padding-top: 0; height: auto; transform: rotate(90deg); margin: 4px 0; }
}

/* ── Utility text ───────────────────────────────────────────────── */
.text-muted { color: var(--muted); }
.text-mono { font-family: var(--mono); }
.flex-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Footer ─────────────────────────────────────────────────────── */
footer {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 24px; font-size: 11px; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
