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

:root {
  --y: #f0eb3a;
  --k: #0a0a0a;
  --w: #f5f5f0;
  --g: #1a1a1a;
  --mid: #888;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Space Mono', monospace;
  background: var(--k);
  color: var(--w);
  min-height: 100vh;
}

/* ── MASTHEAD ── */
#masthead {
  background: var(--y);
  color: var(--k);
  border-bottom: 4px solid var(--k);
  position: sticky;
  top: 0;
  z-index: 100;
}

.mast-top {
  display: flex;
  align-items: stretch;
  border-bottom: 3px solid var(--k);
}

.mast-logo {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -2px;
  padding: 14px 24px;
  border-right: 3px solid var(--k);
  line-height: 1;
  flex-shrink: 0;
}

.mast-sub {
  padding: 8px 20px;
  font-size: 10px;
  letter-spacing: 3px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 3px solid var(--k);
  flex: 1;
}

.mast-sub .line1 { font-weight: 700; margin-bottom: 2px; }
.mast-sub .line2 { color: #555; }

.mast-add {
  background: var(--k);
  color: var(--y);
  border: none;
  padding: 0 28px;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.1s;
}
.mast-add:hover { background: #222; }

.mast-ticker {
  background: var(--k);
  color: var(--y);
  padding: 6px 24px;
  font-size: 10px;
  letter-spacing: 2px;
  white-space: nowrap;
  overflow: hidden;
}

.ticker-inner {
  display: inline-block;
  animation: tick 18s linear infinite;
}

@keyframes tick {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ── TOOLBAR ── */
#toolbar {
  background: var(--k);
  border-bottom: 3px solid var(--y);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#toolbar::-webkit-scrollbar { display: none; }

#search-box {
  background: transparent;
  border: none;
  border-right: 2px solid var(--y);
  color: var(--y);
  padding: 12px 20px;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  outline: none;
  width: 220px;
  flex-shrink: 0;
}
#search-box::placeholder { color: #555; }

.cat-pill {
  background: transparent;
  border: none;
  border-right: 1px solid #333;
  color: #777;
  padding: 12px 16px;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.1s;
}
.cat-pill:hover { color: var(--y); background: #111; }
.cat-pill.active { background: var(--y); color: var(--k); font-weight: 700; }

/* ── RECIPE GRID ── */
#recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.recipe-card {
  border-right: 2px solid #222;
  border-bottom: 2px solid #222;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.1s;
  background: var(--k);
}
.recipe-card:hover { background: #111; }
.recipe-card:hover .card-bar { background: var(--y); }

.card-bar { height: 6px; background: #333; transition: background 0.1s; }
.card-inner { padding: 20px 20px 18px; }

.card-num {
  font-size: 10px;
  color: #444;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.card-category {
  display: inline-block;
  background: var(--y);
  color: var(--k);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 3px 8px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -1px;
  margin-bottom: 12px;
  color: var(--w);
  text-transform: uppercase;
}

.card-meta {
  font-size: 10px;
  color: #555;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.card-desc {
  font-size: 12px;
  color: #666;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  border-left: 2px solid #333;
  padding-left: 10px;
}

.card-actions {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  opacity: 0;
  transition: opacity 0.1s;
}
.recipe-card:hover .card-actions { opacity: 1; }

.card-btn {
  width: 36px;
  height: 36px;
  background: #222;
  border: none;
  border-left: 1px solid #333;
  border-bottom: 1px solid #333;
  color: #888;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  font-weight: 700;
}
.card-btn:hover { background: var(--y); color: var(--k); }

/* touch devices: always show actions */
@media (hover: none) {
  .card-actions { opacity: 1; }
}

/* ── EMPTY STATE ── */
.empty-state {
  grid-column: 1/-1;
  padding: 80px 32px;
  text-align: center;
  border: 2px dashed #333;
  margin: 32px;
}
.empty-state p {
  font-size: 16px;
  color: #555;
  margin-bottom: 20px;
  letter-spacing: 1px;
}

/* ── MODAL ── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
}
#modal-overlay.open { display: flex; }

#modal {
  background: var(--k);
  width: 100%;
  max-width: 660px;
  border: 3px solid var(--y);
  position: relative;
}

.modal-head {
  background: var(--y);
  color: var(--k);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-head-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -1px;
  text-transform: uppercase;
}

#close-modal {
  background: var(--k);
  color: var(--y);
  border: none;
  width: 32px;
  height: 32px;
  font-family: 'Space Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
#close-modal:hover { background: #333; }

.modal-body { padding: 28px 24px; }

.form-row { margin-bottom: 18px; }
.form-row label {
  display: block;
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--y);
  margin-bottom: 6px;
  font-weight: 700;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  background: #111;
  border: 2px solid #333;
  color: var(--w);
  padding: 10px 14px;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  outline: none;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus { border-color: var(--y); }
.form-row textarea { resize: vertical; min-height: 90px; }
.form-row select { appearance: none; cursor: pointer; }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.modal-actions {
  display: flex;
  border-top: 2px solid #333;
}

.btn-primary {
  background: var(--y);
  color: var(--k);
  border: none;
  padding: 14px 28px;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  flex: 1;
}
.btn-primary:hover { background: #ffe500; }

.btn-ghost {
  background: transparent;
  color: #666;
  border: none;
  border-left: 2px solid #333;
  padding: 14px 24px;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--w); background: #111; }

/* ── DETAIL VIEW ── */
#detail-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--k);
  z-index: 300;
  overflow-y: auto;
}
#detail-overlay.open { display: block; }

#detail-head {
  background: var(--y);
  color: var(--k);
  border-bottom: 4px solid var(--k);
}

.detail-nav {
  padding: 12px 32px;
  border-bottom: 2px solid rgba(0,0,0,0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#detail-back {
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--k);
}
#detail-back:hover { text-decoration: underline; }

#detail-index-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(0,0,0,0.4);
}

.detail-hero { padding: 32px 32px 28px; }

#detail-cat-tag {
  display: inline-block;
  background: var(--k);
  color: var(--y);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 4px 10px;
  margin-bottom: 14px;
}

#detail-title {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -3px;
  line-height: 0.95;
  text-transform: uppercase;
  color: var(--k);
  margin-bottom: 16px;
}

#detail-meta {
  font-size: 11px;
  color: rgba(0,0,0,0.5);
  letter-spacing: 1px;
}

#detail-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 32px 80px;
}

#detail-desc {
  font-size: 14px;
  line-height: 1.7;
  color: #888;
  border-left: 4px solid var(--y);
  padding-left: 18px;
  margin-bottom: 40px;
  font-style: italic;
}

#detail-body {
  display: grid;
  grid-template-columns: 1fr 1.7fr;
  gap: 32px;
}

.detail-section-head {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--y);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--y);
  margin-bottom: 16px;
}

#detail-ing-list { list-style: none; }
#detail-ing-list li {
  font-size: 13px;
  padding: 9px 0;
  border-bottom: 1px solid #1e1e1e;
  color: #ccc;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
#detail-ing-list li::before {
  content: "//";
  color: var(--y);
  font-weight: 700;
  font-size: 11px;
}

#detail-steps-list { list-style: none; counter-reset: s; }
#detail-steps-list li {
  counter-increment: s;
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid #1e1e1e;
  font-size: 13px;
  color: #ccc;
  line-height: 1.6;
}
#detail-steps-list li::before {
  content: counter(s, decimal-leading-zero);
  font-size: 20px;
  font-weight: 700;
  color: var(--y);
  min-width: 28px;
  line-height: 1.1;
}

#detail-footer {
  display: flex;
  margin-top: 40px;
  border: 2px solid #333;
}
#detail-footer button {
  flex: 1;
  padding: 14px;
  background: transparent;
  border: none;
  border-right: 2px solid #333;
  color: #888;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
}
#detail-footer button:last-child { border-right: none; }
#detail-footer button:hover { background: var(--y); color: var(--k); }
#detail-footer .del-btn:hover { background: #c0392b; color: var(--w); }

/* ── TOAST ── */
#toast {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--y);
  color: var(--k);
  padding: 14px 32px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  display: none;
  z-index: 500;
}
#toast.visible { display: block; }

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  .mast-logo { font-size: 24px; padding: 12px 16px; }
  .mast-sub { display: none; }
  .mast-add { padding: 0 16px; font-size: 11px; }

  #toolbar { padding: 0; }
  #search-box { width: 140px; padding: 10px 12px; font-size: 12px; }
  .cat-pill { padding: 10px 12px; font-size: 9px; }

  #recipe-grid { grid-template-columns: 1fr 1fr; }
  .card-title { font-size: 18px; }

  #detail-title { font-size: 30px; letter-spacing: -1px; }
  #detail-body { grid-template-columns: 1fr; }
  .detail-hero { padding: 20px; }
  #detail-inner { padding: 20px 20px 60px; }
  .detail-nav { padding: 10px 16px; }

  #modal { margin: 0; }
  .modal-body { padding: 20px 16px; }
  .form-2col { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  #recipe-grid { grid-template-columns: 1fr; }
}
