:root {
  --bg: #0f172a;
  --panel: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #22c55e;
  --accent-fg: #062e12;
  --border: #1f2937;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

h1 {
  margin: 0 0 16px;
  font-size: 28px;
}

.page-title {
  font-size: 34px;
  margin: 0 0 20px;
  font-weight: 700;
  position: relative;
  padding-bottom: 12px;
}

.page-title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 64px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.recipes {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.recipes li a {
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  text-decoration: none;
  min-height: 88px;
}

.recipes-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  color: var(--muted);
  font-weight: 500;
}

.recipe-label {
  display: block;
  width: 100%;
  line-height: 1.3;
  font-weight: 600;
  max-height: calc(1.3em * 2);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.recipes li a:hover {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.secondary { color: var(--muted); }

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.link-back {
  color: var(--muted);
}

.link-back:hover {
  color: var(--accent);
}

.content {
  margin-top: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.content h1, .content h2, .content h3 {
  margin: 1.6em 0 0.6em;
  line-height: 1.25;
  padding: 8px 12px;
  border-left: 4px solid var(--accent);
  background: rgba(34, 197, 94, 0.08);
  border-radius: 6px;
}

.content p { margin: 0.5em 0; }
.content ul, .content ol { padding-left: 20px; }
.content blockquote { margin: 12px 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.content img { max-width: 100%; height: auto; border-radius: 6px; }
.content table { border-collapse: collapse; width: 100%; }
.content th, .content td { border: 1px solid var(--border); padding: 6px 8px; }
.content pre { overflow: auto; background: #0b1220; padding: 12px; border-radius: 6px; }
.content code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

.form-card {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.new-recipe-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
}

.form-field label {
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 600;
}

.form-field input,
.form-field textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}

.editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.editor-toolbar button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 500;
  box-shadow: none;
  transform: none;
}

.editor-toolbar button:hover {
  transform: none;
  background: rgba(34, 197, 94, 0.15);
  box-shadow: none;
}

.editor-toolbar button.is-active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.editor-preview {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: #0b1220;
  min-height: 140px;
  line-height: 1.45;
}

.editor-preview[hidden] {
  display: none;
}

.preview-error {
  color: #f87171;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 9999px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn:hover,
button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(34, 197, 94, 0.2);
}

.btn:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-secondary:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 640px) {
  .recipes { grid-template-columns: 1fr; }
}
