:root {
  color-scheme: dark;
  --bg: #111827;
  --panel: #182236;
  --panel-2: #202b43;
  --ink: #fffdf8;
  --muted: rgba(255, 253, 248, 0.68);
  --line: rgba(255, 255, 255, 0.12);
  --accent: #0ea5e9;
  --accent-2: #f97316;
  --good: #22c55e;
  --danger: #ef4444;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(14, 165, 233, 0.18), transparent 34rem),
    linear-gradient(135deg, #111827 0%, #151b2b 48%, #111827 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 34, 54, 0.92);
  box-shadow: var(--shadow);
}

.brand-mark img {
  width: 58px;
  height: 58px;
  border-radius: 8px;
}

.auth-card h1 {
  margin-top: 8px;
  font-size: 42px;
  line-height: 1;
}

.auth-copy {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-form,
.modal-panel {
  display: grid;
  gap: 12px;
}

.auth-form {
  margin-top: 20px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: 82px;
  padding: 10px 11px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 75%, white);
}

.btn,
.icon-btn,
.week-label,
.link-btn {
  border: 0;
  border-radius: 7px;
  font-weight: 800;
}

.btn {
  min-height: 40px;
  padding: 0 14px;
  color: var(--ink);
}

.btn.primary {
  background: var(--accent);
  color: #06131d;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
}

.link-btn {
  margin-top: 14px;
  padding: 0;
  background: transparent;
  color: var(--accent);
}

.form-error {
  min-height: 20px;
  color: #fca5a5;
  font-size: 13px;
}

.app {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 12px;
}

.top-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.app-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 8px;
}

.topbar h1 {
  font-size: clamp(25px, 3.6vw, 38px);
  line-height: 1.02;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.layout {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding-bottom: 32px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 34, 54, 0.78);
}

.select-wrap span {
  color: var(--muted);
}

.week-switch {
  display: grid;
  grid-template-columns: 40px minmax(190px, auto) 40px;
  gap: 8px;
}

.week-label {
  min-height: 40px;
  padding: 0 14px;
  background: var(--panel-2);
  color: var(--ink);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(128px, 1fr));
  gap: 10px;
}

.day-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 34, 54, 0.84);
  overflow: hidden;
}

.day-card header {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.day-card header span {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
  text-transform: capitalize;
}

.day-card header strong {
  color: var(--accent);
  font-size: 22px;
}

.slot {
  width: calc(100% - 16px);
  margin: 8px;
  border-radius: 8px;
}

.slot.empty {
  display: grid;
  min-height: 92px;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.slot.empty strong {
  color: var(--accent);
  font-size: 24px;
}

.slot.filled {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
}

.slot.filled.recipe {
  border-color: color-mix(in srgb, var(--accent) 48%, transparent);
}

.slot.filled.free {
  border-color: color-mix(in srgb, var(--accent-2) 52%, transparent);
}

.slot-main {
  display: grid;
  width: 100%;
  min-height: 92px;
  gap: 5px;
  padding: 11px 34px 11px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.slot-main span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.slot-main strong {
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.slot-main em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.slot-clear {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--muted);
  font-weight: 900;
}

.empty-state {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 34, 54, 0.84);
}

.empty-state h2 {
  font-size: 20px;
}

.empty-state p,
.muted {
  margin-top: 6px;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 9, 16, 0.72);
}

.modal-panel {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #172033;
  box-shadow: var(--shadow);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-head h2 {
  margin-top: 3px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.segmented button {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.segmented button.active {
  background: var(--accent);
  color: #06131d;
}

.search-input {
  margin-bottom: 10px;
}

.recipe-results {
  display: grid;
  max-height: 260px;
  gap: 8px;
  overflow: auto;
}

.recipe-option {
  display: grid;
  gap: 5px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  text-align: left;
}

.recipe-option.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.recipe-option span {
  color: var(--muted);
  font-size: 13px;
}

.modal-actions {
  justify-content: flex-end;
}

.modal-actions .danger {
  margin-right: auto;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #111827;
  font-weight: 850;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

@media (max-width: 1040px) {
  .week-grid {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .primary {
    flex: 1;
  }

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

  .week-switch {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

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

  .day-card {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) minmax(0, 1fr);
  }

  .day-card header {
    min-height: 100%;
    align-items: flex-start;
    flex-direction: column;
    grid-row: 1 / span 2;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .slot {
    grid-column: 2;
    width: calc(100% - 12px);
    margin: 6px;
  }

  .slot.empty,
  .slot-main {
    min-height: 86px;
  }
}

@media (max-width: 480px) {
  .auth-screen {
    padding: 14px;
  }

  .topbar,
  .layout {
    width: min(100vw - 36px, 1180px);
  }

  .day-card {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .slot.filled,
  .slot.empty {
    min-width: 0;
  }

  .modal {
    padding: 10px;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .modal-actions .danger {
    grid-column: 1 / -1;
    margin-right: 0;
  }
}
