:root {
  --bg: #0b0f14;
  --card: #121a22;
  --text: #e9eef5;
  --muted: #a9b4c2;
  --line: #223041;
  --btn: #3a8bfd;
  --btn2: #243244;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: radial-gradient(1200px 800px at 20% 0%, #142238 0%, var(--bg) 55%);
  color: var(--text);
}

.wrap { max-width: 860px; margin: 0 auto; padding: 22px; }
.hero { padding: 14px 6px 18px; }
h1 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 44px); letter-spacing: -0.02em; }
p { margin: 0; color: var(--muted); line-height: 1.5; }

.card {
  background: rgba(18,26,34,0.86);
  border: 1px solid rgba(34,48,65,0.75);
  border-radius: 18px;
  padding: 16px;
  margin: 14px 0;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  backdrop-filter: blur(8px);
}

.label { display: block; margin: 10px 0 6px; color: var(--muted); font-size: 13px; }

textarea, input {
  width: 100%;
  background: #0e141c;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
}
textarea { resize: vertical; min-height: 90px; }

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btnPrimary, .btnSecondary, .theme-toggle, .iconBtn {
  border: 1px solid rgba(34,48,65,0.9);
  background: rgba(18,26,34,0.92);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}

.btnPrimary {
  background: linear-gradient(180deg, rgba(58,139,253,0.95), rgba(58,139,253,0.7));
  border-color: rgba(58,139,253,0.8);
}

.btnPrimary:disabled,
.btnSecondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.result {
  margin-top: 12px;
  padding: 12px 14px;
  background: #0e141c;
  border: 1px solid rgba(34,48,65,0.9);
  border-radius: 14px;
  white-space: pre-wrap;
  overflow: auto;
  min-height: 140px;
  font-size: 14px;
  line-height: 1.45;
}

.fineprint { margin-top: 10px; font-size: 13px; color: var(--muted); }
.footer { padding: 10px 6px 22px; color: var(--muted); font-size: 13px; }

.error {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 80, 80, 0.10);
  border: 1px solid rgba(255, 80, 80, 0.25);
  color: #ffd2d2;
}

/* Theme toggle */
.theme-toggle { white-space: nowrap; }

/* Light theme support (theme.js uses data-theme="light") */
:root[data-theme="light"] {
  --bg: #f7f9fc;
  --card: #ffffff;
  --text: #0b0f14;
  --muted: #4a5568;
  --line: rgba(0,0,0,0.15);
  --btn2: rgba(0,0,0,0.06);
}
:root[data-theme="light"] body {
  background: radial-gradient(1200px 800px at 20% 0%, #e8f1ff 0%, #f7f9fc 55%);
}
:root[data-theme="light"] .card {
  background: rgba(255,255,255,0.92);
  border-color: rgba(0,0,0,0.12);
}
:root[data-theme="light"] textarea,
:root[data-theme="light"] input,
:root[data-theme="light"] .result{
  background: rgba(255,255,255,0.95);
  border-color: rgba(0,0,0,0.14);
  color: #0b0f14;
}
:root[data-theme="light"] .theme-toggle{
  border-color: rgba(0,0,0,0.14);
  background: rgba(255,255,255,0.9);
}

/* ===========================
   Saved recipes UI additions
   =========================== */

.hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Modal */
.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}

.modal-panel {
  position: relative;
  width: min(760px, calc(100vw - 28px));
  margin: 64px auto;
  background: rgba(18,26,34,0.95);
  border: 1px solid rgba(34,48,65,0.85);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

:root[data-theme="light"] .modal-panel {
  background: rgba(255,255,255,0.96);
  border-color: rgba(0,0,0,0.14);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(34,48,65,0.65);
}

:root[data-theme="light"] .modal-header {
  border-bottom-color: rgba(0,0,0,0.10);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.iconBtn {
  padding: 8px 10px;
  border-radius: 12px;
}

.modal-body {
  padding: 12px 14px 16px;
}

.muted {
  color: var(--muted);
  margin: 8px 0 12px;
  font-size: 14px;
}

.saved-list {
  display: grid;
  gap: 10px;
}

.saved-item {
  border: 1px solid rgba(34,48,65,0.75);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(14,20,28,0.7);
}

:root[data-theme="light"] .saved-item {
  background: rgba(255,255,255,0.85);
  border-color: rgba(0,0,0,0.12);
}

.saved-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.saved-title {
  font-weight: 700;
  font-size: 14px;
  margin: 0;
}

.saved-meta {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.saved-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btnMini {
  border: 1px solid rgba(34,48,65,0.9);
  background: rgba(18,26,34,0.92);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

:root[data-theme="light"] .btnMini {
  background: rgba(255,255,255,0.92);
  border-color: rgba(0,0,0,0.14);
  color: #0b0f14;
}

/* Keep Time + Servings side-by-side even on small phones */
@media (max-width: 300px) {
  .row { grid-template-columns: 1fr; }
}

/* ===========================
   Light theme button fixes
   =========================== */

:root[data-theme="light"] .btnSecondary,
:root[data-theme="light"] .btnMini,
:root[data-theme="light"] .iconBtn {
  background: #ffffff;
  color: #0b0f14;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

:root[data-theme="light"] .btnSecondary:hover,
:root[data-theme="light"] .btnMini:hover,
:root[data-theme="light"] .iconBtn:hover {
  background: #f2f5fa;
}

/* Disabled buttons should still look disabled */
:root[data-theme="light"] .btnSecondary:disabled,
:root[data-theme="light"] .btnMini:disabled {
  background: #e5e9f0;
  color: #7a8595;
  border-color: rgba(0, 0, 0, 0.12);
  cursor: not-allowed;
}

/* Modal close button (✕) extra clarity */
:root[data-theme="light"] .modal-header .iconBtn {
  font-size: 16px;
  line-height: 1;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
