:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --panel: #fffaf2;
  --panel-2: #ffffff;
  --text: #2f261d;
  --muted: #76685a;
  --line: #eadfce;
  --accent: #b45309;
  --accent-2: #f59e0b;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow: 0 18px 50px rgba(70, 45, 20, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

.recipe-item {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
}

.thumb {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  background: #f3f4f6;
  border: 1px solid var(--line);
}

.thumb.pdf {
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  color: #92400e;
}

.thumb.empty {
  background: #fef3c7;
  color: #92400e;
}

.recipe-content {
  min-width: 0;
}

.recipe-content strong {
  display: block;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recipe-content small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(245, 158, 11, 0.18), transparent 34rem),
    linear-gradient(135deg, #f8f1e6, var(--bg));
  color: var(--text);
}

button, input, textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 750;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.55; cursor: wait; transform: none; }
button.secondary { background: #3f3429; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--danger); }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.78rem 0.9rem;
  background: #fffdf8;
  color: var(--text);
  outline: none;
}

input:focus, textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
}

textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(430px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 2rem;
  display: grid;
  gap: 1rem;
}

.brand {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 2rem;
}

.login-card h1, .topbar h1 { margin: 0; }
.login-card p { margin: 0; color: var(--muted); }

.app-shell {
  min-height: 100vh;
  padding: 1.1rem;
}

.topbar {
  max-width: 1440px;
  margin: 0 auto 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.eyebrow {
  color: var(--accent);
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.top-actions {
  display: flex;
  gap: 0.7rem;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.42rem 0.7rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.layout {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.sidebar {
  display: grid;
  gap: 1rem;
}

.card, .detail-panel {
  background: rgba(255, 250, 242, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card { padding: 1rem; display: grid; gap: 0.85rem; }

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.section-title h2 { margin: 0; font-size: 1.05rem; }

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.file-label input {
  padding: 0.65rem;
}

.recipe-list {
  display: grid;
  gap: 0.55rem;
  max-height: 62vh;
  overflow: auto;
  padding-right: 0.15rem;
}

.recipe-item {
  width: 100%;
  border-radius: 16px;
  padding: 0.8rem;
  background: #fffdf8;
  color: var(--text);
  border: 1px solid var(--line);
  text-align: left;
  display: grid;
  gap: 0.35rem;
}

.recipe-item.active {
  border-color: var(--accent-2);
  background: #fff7ed;
}

.recipe-item strong { font-size: 0.98rem; }
.recipe-item small { color: var(--muted); line-height: 1.35; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  border-radius: 999px;
  padding: 0.22rem 0.5rem;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.76rem;
  font-weight: 750;
}

.detail-panel {
  min-height: calc(100vh - 132px);
  padding: 1.1rem;
  display: grid;
  gap: 1rem;
}

.empty-state {
  min-height: 55vh;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 0.55rem;
  color: var(--muted);
}

.empty-state div { font-size: 3rem; }
.empty-state h2 { margin: 0; color: var(--text); }

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.detail-header h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.meta {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem;
}

.meta span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.25rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  font-weight: 800;
  font-size: 0.82rem;
}

.status.done { background: #dcfce7; color: #166534; }
.status.pending, .status.running { background: #fef3c7; color: #92400e; }
.status.failed { background: #fee2e2; color: #991b1b; }
.status.not_started { background: #e5e7eb; color: #374151; }

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.7rem;
}

.file-card {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.8rem;
  display: grid;
  gap: 0.45rem;
}

.file-card a {
  color: var(--accent);
  font-weight: 800;
  word-break: break-word;
}

.preview-img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.error, .toast {
  color: var(--danger);
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10;
  background: #2f261d;
  color: white;
  padding: 0.8rem 1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.progress-line {
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .recipe-list { max-height: 36vh; }
  .detail-panel { min-height: auto; }
  .editor-grid, .meta-grid { grid-template-columns: 1fr; }
  .topbar { align-items: start; flex-direction: column; }
}

@media (max-width: 560px) {
  .app-shell { padding: 0.65rem; }
  .card, .detail-panel { border-radius: 16px; }
}
