@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,500;0,600;1,500&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --graphite: #121214;
  --charcoal: #1d1d20;
  --charcoal-2: #292a2e;
  --warm-white: #f5f3ef;
  --text-muted: #6b6a66;
  --text-on-dark-muted: #b7b4ae;
  --rule: #e4e1da;
  --rule-dark: #36363a;
  --sage: #6b7a6a;
  --sage-bg: rgba(107,122,106,0.12);
  --danger: #a1453d;
  --danger-bg: rgba(161,69,61,0.1);
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --radius: 10px;
  --chrome-1: #c4c7cb;
  --chrome-2: #9ba0a7;
  --chrome-shine: linear-gradient(135deg, #eef0f2 0%, #c4c7cb 35%, #868a92 55%, #d4d7db 75%, #eef0f2 100%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--warm-white);
  color: var(--graphite);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.wrap { max-width: 920px; margin: 0 auto; padding: 0 1.5rem; }

/* HEADER */
.app-header {
  background: var(--charcoal);
  color: var(--warm-white);
  padding: 1.25rem 0;
  position: relative;
}
.app-header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--chrome-shine); background-size: 200% 100%;
}
.app-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.app-logo { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; text-decoration: none; color: var(--warm-white); display: flex; align-items: center; gap: 0.6rem; }
.app-logo span { font-family: var(--font-body); font-weight: 500; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-on-dark-muted); }
.app-logo__mark {
  width: 26px; height: 26px; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--chrome-shine);
}
.app-logo__mark svg { width: 14px; height: 14px; display: block; }
.app-header__user { font-size: 0.85rem; color: var(--text-on-dark-muted); }

/* MAIN */
main { padding: 2.5rem 0 5rem; }

.page-head { position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 2rem; }
.page-head h1 { font-family: var(--font-display); font-weight: 600; font-size: 1.9rem; margin: 0 0 0.35rem; letter-spacing: -0.01em; }
.page-head p { margin: 0; color: var(--text-muted); font-size: 0.95rem; max-width: 46ch; }

.eyebrow { display: flex; align-items: center; gap: 0.6em; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--sage); margin: 0 0 0.6rem; }
.eyebrow::before { content: ""; width: 1.75em; height: 1px; background: var(--chrome-2); display: inline-block; }

/* DECORATIVE */
.ghost-num {
  position: absolute; top: -1.6rem; right: -0.5rem;
  font-family: var(--font-display); font-weight: 600; font-style: italic;
  font-size: clamp(5rem, 11vw, 9rem); line-height: 0.8; color: var(--graphite);
  opacity: 0.04; pointer-events: none; user-select: none; z-index: 0;
}
.icon-chip { display: inline-flex; width: 44px; height: 44px; flex-shrink: 0; }
.icon-chip svg { width: 100%; height: 100%; display: block; }
.icon-chip--sm { width: 32px; height: 32px; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: var(--font-body); font-weight: 600; font-size: 0.9rem;
  padding: 0.7rem 1.3rem; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: opacity 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--charcoal); color: var(--warm-white); }
.btn--primary:hover { opacity: 0.88; }
.btn--ghost { background: transparent; color: var(--graphite); border-color: var(--rule); }
.btn--ghost:hover { background: rgba(0,0,0,0.03); }
.btn--sage { background: var(--sage); color: var(--warm-white); }
.btn--sage:hover { opacity: 0.9; }
.btn--danger { background: transparent; color: var(--danger); border-color: rgba(161,69,61,0.3); }
.btn--danger:hover { background: var(--danger-bg); }
.btn--sm { padding: 0.45rem 0.9rem; font-size: 0.8rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn-soul {
  display: inline-flex; align-items: center; gap: 0.8rem;
  padding: 0.35rem 0.35rem 0.35rem 1.2rem; border-radius: 999px; border: 1px solid currentColor;
  text-decoration: none; font-weight: 600; font-size: 0.82rem; letter-spacing: 0.02em; text-transform: uppercase;
  cursor: pointer; background: transparent; color: var(--charcoal);
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.2s ease;
}
.btn-soul:hover { transform: translateY(-2px); background: var(--charcoal); color: var(--warm-white); }
.btn-soul:hover .btn-soul__ring { background: var(--warm-white); color: var(--charcoal); transform: rotate(45deg); }
.btn-soul[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-soul__ring {
  flex-shrink: 0; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 0.9rem;
  background: var(--charcoal); color: var(--warm-white);
  transition: transform 0.3s ease, background-color 0.25s ease, color 0.25s ease;
}

/* SEARCH / FILTER */
.toolbar { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.toolbar input[type="text"] {
  flex: 1; min-width: 220px; padding: 0.7rem 1rem; border-radius: 999px;
  border: 1px solid var(--rule); font-family: var(--font-body); font-size: 0.9rem; background: #fff;
}
.toolbar input[type="text"]:focus { outline: 2px solid var(--sage); outline-offset: 1px; }

/* WORKFLOW CARDS */
.wf-list { display: flex; flex-direction: column; gap: 0.85rem; }
.wf-card {
  position: relative; overflow: hidden;
  background: #fff; border: 1px solid var(--rule); border-radius: 14px;
  padding: 1.1rem 1.3rem 1.1rem 1.6rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  box-shadow: 0 1px 2px rgba(18,18,20,0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.wf-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--sage);
  opacity: 0.55; transition: opacity 0.2s ease;
}
.wf-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -18px rgba(18,18,20,0.35);
  border-color: rgba(107,122,106,0.35);
}
.wf-card:hover::before { opacity: 1; }
.wf-card__main { min-width: 0; }
.wf-card__name { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; margin: 0 0 0.25rem; letter-spacing: -0.005em; }
.wf-card__meta { font-size: 0.82rem; color: var(--text-muted); display: flex; gap: 0.6rem; flex-wrap: wrap; }
.wf-card__meta .dot { opacity: 0.5; }
.wf-card__actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.empty-state { text-align: center; padding: 4rem 1rem; color: var(--text-muted); }
.empty-state h2 { font-family: var(--font-display); font-weight: 600; color: var(--graphite); font-size: 1.3rem; margin: 0 0 0.5rem; }

/* EDITOR FORM */
.field { margin-bottom: 1.4rem; }
.field label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.4rem; }
.field .hint { font-weight: 400; color: var(--text-muted); font-size: 0.78rem; margin-left: 0.4rem; }
.field input[type="text"], .field textarea {
  width: 100%; padding: 0.7rem 0.9rem; border-radius: 8px; border: 1px solid var(--rule);
  font-family: var(--font-body); font-size: 0.95rem; background: #fff; resize: vertical;
}
.field input[type="text"]:focus, .field textarea:focus { outline: 2px solid var(--sage); outline-offset: 1px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

.steps-head { display: flex; align-items: center; justify-content: space-between; margin: 2.2rem 0 1rem; }
.steps-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; margin: 0; }

.steps-flow { position: relative; }
.step-card {
  position: relative;
  background: #fff; border: 1px solid var(--rule); border-radius: 14px;
  padding: 1.1rem 1.2rem; margin-bottom: 1.6rem; display: flex; gap: 1rem;
  box-shadow: 0 1px 2px rgba(18,18,20,0.04);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.step-card:focus-within { border-color: rgba(107,122,106,0.4); box-shadow: 0 10px 24px -18px rgba(18,18,20,0.4); }
.step-card:not(:last-child)::after {
  content: "";
  position: absolute; left: 34px; bottom: -1.6rem;
  width: 2px; height: 1.3rem;
  background: var(--chrome-2);
}
.step-card:not(:last-child)::before {
  content: "";
  position: absolute; left: 28px; bottom: -0.55rem;
  width: 0; height: 0;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-top: 7px solid var(--chrome-2);
}
.step-card__num {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 999px; background: var(--chrome-shine); color: var(--graphite);
  display: flex; align-items: center; justify-content: center; font-size: 0.82rem; font-weight: 700; margin-top: 0.15rem;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}
.step-card__body { flex: 1; min-width: 0; }
.step-card__body input[type="text"] { font-weight: 600; margin-bottom: 0.5rem; }
.step-card__controls { display: flex; flex-direction: column; gap: 0.35rem; flex-shrink: 0; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--rule); background: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; color: var(--text-muted);
}
.icon-btn:hover { background: rgba(0,0,0,0.03); color: var(--graphite); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.icon-btn--danger:hover { color: var(--danger); border-color: rgba(161,69,61,0.3); background: var(--danger-bg); }

/* RICH TEXT DESCRIPTION */
.rte-toolbar { display: flex; gap: 0.25rem; margin-bottom: 0.4rem; flex-wrap: wrap; }
.rte-btn {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--rule); background: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--text-muted);
  font-family: var(--font-body);
}
.rte-btn:hover { background: rgba(0,0,0,0.03); color: var(--graphite); }
.rte-btn.is-active { background: var(--charcoal); color: var(--warm-white); border-color: var(--charcoal); }
.rte-btn--b { font-weight: 700; }
.rte-btn--i { font-style: italic; }
.rte-btn--u { text-decoration: underline; }

.step-desc {
  width: 100%; min-height: 64px; padding: 0.6rem 0.8rem; border-radius: 8px; border: 1px solid var(--rule);
  font-family: var(--font-body); font-size: 0.92rem; background: #fff; line-height: 1.5;
}
.step-desc:focus { outline: 2px solid var(--sage); outline-offset: 1px; }
.step-desc ul, .step-desc ol { margin: 0.3em 0; padding-left: 1.4em; }
.step-desc a { color: var(--sage); }
.step-desc:empty::before { content: attr(data-placeholder); color: #9a9892; }

/* STEP IMAGE */
.step-image-zone { margin-top: 0.6rem; }
.step-image-drop {
  border: 1.5px dashed var(--rule); border-radius: 8px; padding: 0.75rem; text-align: center;
  font-size: 0.78rem; color: var(--text-muted); cursor: pointer;
}
.step-image-drop:hover { border-color: var(--sage); color: var(--sage); }
.step-image-preview { position: relative; display: inline-block; margin-top: 0.5rem; }
.step-image-preview[hidden] { display: none; }
.step-image-preview img { max-width: 220px; max-height: 140px; border-radius: 8px; border: 1px solid var(--rule); display: block; }
.step-image-remove {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 999px;
  background: var(--charcoal); color: var(--warm-white); border: none; cursor: pointer; font-size: 0.7rem;
  display: flex; align-items: center; justify-content: center;
}

/* TASK LIST */
.task-list-zone { margin-top: 0.75rem; }
.task-list-rows { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.5rem; }
.task-row { display: flex; align-items: center; gap: 0.6rem; }
.task-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--sage); flex-shrink: 0; cursor: pointer; }
.task-row input[type="text"] { flex: 1; padding: 0.4rem 0.6rem; border-radius: 6px; border: 1px solid var(--rule); font-size: 0.86rem; }
.task-row input[type="text"]:focus { outline: 2px solid var(--sage); outline-offset: 1px; }
.task-row__remove {
  width: 22px; height: 22px; border-radius: 6px; border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; flex-shrink: 0; font-size: 0.8rem; display: flex; align-items: center; justify-content: center;
}
.task-row__remove:hover { background: var(--danger-bg); color: var(--danger); }
.add-task-btn {
  padding: 0.4rem 0.8rem; border-radius: 999px; border: 1px dashed var(--rule); background: transparent;
  color: var(--text-muted); font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.add-task-btn:hover { border-color: var(--sage); color: var(--sage); }

.add-step-btn {
  width: 100%; padding: 0.85rem; border-radius: var(--radius); border: 1.5px dashed var(--rule);
  background: transparent; color: var(--text-muted); font-family: var(--font-body); font-weight: 600; font-size: 0.88rem;
  cursor: pointer;
}
.add-step-btn:hover { border-color: var(--sage); color: var(--sage); }

.editor-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 2.5rem; gap: 1rem; flex-wrap: wrap; }
.editor-actions__left, .editor-actions__right { display: flex; gap: 0.6rem; }

.save-status { font-size: 0.8rem; color: var(--text-muted); }
.save-status--ok { color: var(--sage); }

.back-link { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--text-muted); text-decoration: none; margin-bottom: 1.5rem; }
.back-link:hover { color: var(--graphite); }

/* LOGIN GATE (fallback if Cloudflare Access isn't configured yet) */
.gate-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, var(--charcoal-2) 0%, var(--graphite) 65%);
  padding: 1.5rem;
}
.gate-box {
  position: relative; background: var(--warm-white); border-radius: 18px; padding: 2.75rem 2.5rem 2.5rem;
  max-width: 360px; width: 100%; text-align: center;
  box-shadow: 0 40px 80px -30px rgba(0,0,0,0.55);
}
.gate-box::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; border-radius: 18px 18px 0 0;
  background: var(--chrome-shine); background-size: 200% 100%;
}
.gate-box__mark {
  display: flex; align-items: center; justify-content: center; margin: 0 auto 1.25rem;
  width: 54px; height: 54px; border-radius: 999px; background: var(--chrome-shine);
}
.gate-box__mark svg { width: 28px; height: 28px; }
.gate-box h1 { font-family: var(--font-display); font-weight: 600; font-size: 1.4rem; margin: 0 0 0.3rem; }
.gate-box h1 em { font-style: italic; font-weight: 500; }
.gate-box__sub { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--sage); margin: 0 0 1.75rem; }
.password-field { position: relative; margin-bottom: 1rem; }
.gate-box input { width: 100%; padding: 0.8rem 2.75rem 0.8rem 1rem; border-radius: 8px; border: 1px solid var(--rule); font-size: 0.95rem; margin-bottom: 0; }
.gate-box input:focus { outline: 2px solid var(--sage); outline-offset: 1px; }
.password-toggle {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: none; background: transparent; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-muted);
}
.password-toggle:hover { background: rgba(0,0,0,0.04); color: var(--graphite); }
.password-toggle svg { width: 18px; height: 18px; }
.gate-box .error { color: var(--danger); font-size: 0.82rem; margin-top: -0.6rem; margin-bottom: 1rem; }

.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--charcoal); color: var(--warm-white); padding: 0.75rem 1.3rem; border-radius: 999px;
  font-size: 0.85rem; box-shadow: 0 8px 24px rgba(0,0,0,0.2); opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
  z-index: 100;
}
.toast.is-visible { opacity: 1; }
