:root{
  --bg:#f6f0e8;
  --bg-accent:#e0f0ec;
  --surface:#fffdf9;
  --surface-strong:#ffffff;
  --surface-muted:#f1ece4;
  --surface-dark:#153833;
  --text:#1c2422;
  --text-muted:#5e6b67;
  --primary:#0f766e;
  --primary-strong:#0b5a55;
  --danger:#b23831;
  --danger-soft:#f7dbd6;
  --warning:#c9862e;
  --warning-soft:#f8ead1;
  --success:#2f7d4a;
  --success-soft:#d9efdf;
  --border:#d8d0c2;
  --border-strong:#b8af9f;
  --shadow:0 24px 60px rgba(39, 31, 17, 0.12);
  --shadow-soft:0 14px 28px rgba(39, 31, 17, 0.08);
  --radius-xl:28px;
  --radius-lg:20px;
  --radius-md:14px;
  --radius-sm:10px;
  --font-sans:"IBM Plex Sans","Avenir Next","Segoe UI",sans-serif;
  --font-mono:"IBM Plex Mono","SFMono-Regular","Menlo",monospace;
}

*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  margin:0;
  min-height:100vh;
  font-family:var(--font-sans);
  color:var(--text);
  background:
    radial-gradient(circle at top left, rgba(15,118,110,.12), transparent 34%),
    radial-gradient(circle at top right, rgba(201,134,46,.14), transparent 28%),
    linear-gradient(180deg, #f7f3ed 0%, var(--bg) 42%, #efe8de 100%);
}
a{color:inherit;text-decoration:none}
img{max-width:100%;display:block}
h1,h2,h3,p{margin:0}
button,input,textarea,select{font:inherit}
button{cursor:pointer}

.page-shell{
  max-width:1480px;
  margin:0 auto;
  padding:28px 24px 60px;
}

.page-shell-doc{
  max-width:1600px;
}

.topbar{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:22px;
}

.topbar h1{
  font-size:clamp(2rem, 3vw, 3rem);
  letter-spacing:-0.04em;
}

.topbar-actions{
  display:flex;
  align-items:center;
  gap:12px;
}

.topbar-actions-wrap{
  flex-wrap:wrap;
  justify-content:flex-end;
}

.eyebrow,
.card-label,
.doc-card-kicker,
.brand-kicker,
.auth-badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-size:.78rem;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:var(--text-muted);
}

.user-pill{
  border:1px solid rgba(255,255,255,.25);
  background:rgba(21,56,51,.86);
  color:#e9f4f2;
  padding:10px 14px;
  border-radius:999px;
  font-size:.94rem;
}

.hero-grid,
.workspace-grid{
  display:grid;
  gap:20px;
}

.hero-grid{
  grid-template-columns:minmax(0, 1.35fr) minmax(340px, .9fr);
  margin-bottom:22px;
}

.hero-card,
.card,
.create-card,
.auth-panel,
.modal-panel{
  border:1px solid rgba(184,175,159,.75);
  background:rgba(255,253,249,.92);
  backdrop-filter:blur(14px);
  border-radius:var(--radius-xl);
  box-shadow:var(--shadow);
}

.hero-card{
  padding:28px;
  position:relative;
  overflow:hidden;
  background:
    linear-gradient(140deg, rgba(15,118,110,.08), rgba(15,118,110,0) 42%),
    linear-gradient(330deg, rgba(201,134,46,.12), rgba(201,134,46,0) 55%),
    rgba(255,253,249,.94);
}

.hero-copy h2{
  margin-top:10px;
  font-size:clamp(1.7rem, 2.5vw, 2.6rem);
  line-height:1.05;
  letter-spacing:-0.04em;
  max-width:14ch;
}

.hero-copy p{
  margin-top:14px;
  max-width:58ch;
  color:var(--text-muted);
  line-height:1.6;
}

.stats-grid{
  display:grid;
  grid-template-columns:repeat(4, minmax(0,1fr));
  gap:14px;
  margin-top:28px;
}

.stat-tile{
  padding:18px;
  border-radius:var(--radius-lg);
  border:1px solid rgba(184,175,159,.5);
  background:rgba(255,255,255,.72);
}

.stat-tile span{
  display:block;
  color:var(--text-muted);
  margin-bottom:10px;
}

.stat-tile strong{
  font-size:2rem;
  letter-spacing:-0.04em;
}

.create-card,
.card,
.auth-panel,
.modal-panel{
  padding:24px;
}

.create-card h2,
.card h2,
.auth-panel h2{
  margin-top:10px;
  font-size:1.5rem;
  letter-spacing:-0.03em;
}

.stack{
  display:grid;
  gap:16px;
}

.two-col{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:14px;
}

.field-label{
  display:grid;
  gap:8px;
}

.field-label span,
.run-note-box label{
  font-size:.92rem;
  color:var(--text-muted);
}

input[type=text],
input[type=password],
input[type=search],
input[type=number],
textarea,
select{
  width:100%;
  border:1px solid var(--border);
  background:rgba(255,255,255,.86);
  color:var(--text);
  border-radius:16px;
  padding:14px 16px;
  transition:border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

textarea{
  min-height:120px;
  resize:vertical;
}

input:focus,
textarea:focus,
select:focus{
  outline:none;
  border-color:rgba(15,118,110,.72);
  box-shadow:0 0 0 4px rgba(15,118,110,.14);
  background:#fff;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:12px 16px;
  border-radius:999px;
  border:1px solid transparent;
  transition:transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
  white-space:nowrap;
}

.btn:hover{
  transform:translateY(-1px);
}

.btn-primary{
  background:linear-gradient(180deg, var(--primary), var(--primary-strong));
  color:#f5fffd;
  box-shadow:0 12px 24px rgba(15,118,110,.22);
}

.btn-secondary{
  background:#f0ebe3;
  color:var(--text);
  border-color:var(--border);
}

.btn-ghost{
  background:transparent;
  border-color:var(--border);
  color:var(--text);
}

.btn-danger{
  background:var(--danger-soft);
  border-color:#e9bcb5;
  color:#7b1c18;
}

.btn-wide{width:100%}

.muted{color:var(--text-muted)}

.chip-row,
.template-chip-row{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}

.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border-radius:999px;
  background:#ede7df;
  color:var(--text);
  font-size:.9rem;
}

.chip-soft{
  background:#e7f2ef;
  color:var(--primary-strong);
}

.chip-outline{
  border:1px solid var(--border);
  background:transparent;
}

.chip-action{
  border:1px solid transparent;
  background:#f5efe7;
}

.chip-action:hover{
  border-color:rgba(15,118,110,.25);
}

.template-hint{
  display:flex;
  align-items:flex-end;
  justify-content:flex-end;
  gap:8px;
  flex-wrap:wrap;
}

.library-head,
.card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
}

.library-tools{
  width:min(380px, 100%);
}

.doc-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));
  gap:16px;
  margin-top:20px;
}

.doc-card{
  display:grid;
  gap:14px;
  padding:20px;
  border-radius:22px;
  border:1px solid rgba(184,175,159,.65);
  background:linear-gradient(180deg, rgba(255,255,255,.92), rgba(246,241,233,.86));
  box-shadow:var(--shadow-soft);
}

.doc-card.is-hidden,
.step-nav-item.is-hidden,
.entry-card.is-hidden{
  display:none;
}

.doc-card-head{
  display:flex;
  justify-content:space-between;
  gap:12px;
}

.doc-card h3{
  margin-top:8px;
  font-size:1.25rem;
  letter-spacing:-0.03em;
}

.doc-card-desc{
  color:var(--text-muted);
  line-height:1.55;
  min-height:4.6em;
}

.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:7px 11px;
  border-radius:999px;
  font-size:.84rem;
  font-weight:600;
}

.badge-progress{
  background:rgba(15,118,110,.12);
  color:var(--primary-strong);
}

.badge-status{
  border:1px solid transparent;
}

.badge-status-open{
  background:var(--warning-soft);
  color:#9a5e0a;
}

.badge-status-done{
  background:var(--success-soft);
  color:#1d6437;
}

.badge-status-skipped{
  background:#ece7de;
  color:#6f6658;
}

.progress-bar{
  height:10px;
  border-radius:999px;
  background:#ebe4da;
  overflow:hidden;
}

.progress-bar span{
  display:block;
  height:100%;
  border-radius:inherit;
  background:linear-gradient(90deg, #dfb36d, var(--primary));
}

.doc-meta-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:12px;
}

.doc-meta-grid div{
  padding:12px 14px;
  border-radius:16px;
  background:rgba(255,255,255,.72);
  border:1px solid rgba(184,175,159,.4);
}

.doc-meta-grid span{
  display:block;
  font-size:.82rem;
  color:var(--text-muted);
  margin-bottom:6px;
}

.doc-meta-grid strong{
  font-size:1.05rem;
}

.doc-card-footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}

.workspace-grid{
  grid-template-columns:340px minmax(0,1fr);
  align-items:start;
}

.workspace-sidebar{
  position:sticky;
  top:16px;
  display:grid;
  gap:18px;
}

.sidebar-card{
  display:grid;
  gap:14px;
}

.progress-panel{
  display:grid;
  gap:18px;
}

.progress-ring{
  padding:24px;
  border-radius:24px;
  background:linear-gradient(180deg, rgba(15,118,110,.12), rgba(15,118,110,.04));
  border:1px solid rgba(15,118,110,.18);
}

.progress-ring strong{
  display:block;
  font-size:2.6rem;
  line-height:1;
  letter-spacing:-0.05em;
  color:var(--primary-strong);
}

.progress-ring span{
  display:block;
  margin-top:8px;
  color:var(--text-muted);
}

.progress-stats{
  display:grid;
  gap:10px;
}

.progress-stats div{
  display:flex;
  align-items:center;
  justify-content:space-between;
  border-radius:16px;
  border:1px solid rgba(184,175,159,.45);
  background:#fcfaf6;
  padding:12px 14px;
}

.step-nav{
  display:grid;
  gap:8px;
  max-height:58vh;
  overflow:auto;
  padding-right:4px;
}

.step-nav-item{
  display:grid;
  grid-template-columns:auto 1fr;
  gap:12px;
  align-items:flex-start;
  padding:12px 14px;
  border-radius:16px;
  background:#fcfaf6;
  border:1px solid rgba(184,175,159,.42);
}

.step-nav-item span{
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  border-radius:12px;
  background:#ece7de;
  color:var(--text-muted);
  font-weight:700;
}

.step-nav-item strong{
  font-size:.96rem;
  line-height:1.45;
}

.step-nav-item.status-open{
  border-color:#efd39c;
}

.step-nav-item.status-done{
  border-color:#bfe0c9;
}

.step-nav-item.status-skipped{
  border-color:#d8d0c2;
}

.workspace-main{
  display:grid;
  gap:20px;
}

.entry-list-tools{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:wrap;
  text-align:right;
}

.entry-order-state{
  max-width:340px;
}

.source-banner{
  display:flex;
  align-items:center;
  gap:12px;
  background:linear-gradient(90deg, rgba(15,118,110,.09), rgba(15,118,110,0));
}

.fields-table{
  width:100%;
  border-collapse:collapse;
}

.fields-table th,
.fields-table td{
  padding:10px 8px;
  border-bottom:1px solid rgba(184,175,159,.4);
  text-align:left;
}

.row{
  display:flex;
  gap:10px;
  align-items:center;
}

.row-wrap{
  flex-wrap:wrap;
}

.collapsible .collapse-wrap{
  display:grid;
  grid-template-rows:1fr;
  transition:grid-template-rows .22s ease;
}

.collapsible .collapse-content{
  overflow:hidden;
}

.collapsible.is-collapsed .collapse-wrap{
  grid-template-rows:0fr;
}

.composer-card{
  display:grid;
  gap:16px;
}

.composer-actions-inline{
  display:flex;
  gap:10px;
}

.composer-mode-btn.active{
  background:linear-gradient(180deg, var(--primary), var(--primary-strong));
  color:#fff;
  border-color:transparent;
}

.composer-footer{
  display:grid;
  gap:16px;
}

.paste-footer{
  border-top:1px dashed var(--border);
  padding-top:16px;
}

.paste-help{
  margin-top:10px;
  font-size:.92rem;
  line-height:1.5;
}

.paste-help strong{
  color:var(--primary-strong);
}

.paste-zone{
  position:relative;
  min-height:84px;
  display:grid;
  place-items:center;
  border:2px dashed rgba(15,118,110,.3);
  border-radius:20px;
  background:linear-gradient(180deg, rgba(15,118,110,.05), rgba(15,118,110,.02));
  color:var(--text-muted);
  transition:border-color .18s ease, background .18s ease, box-shadow .18s ease;
  outline:none;
}

.paste-zone::after{
  content:attr(data-label);
  text-align:center;
  padding:0 18px;
}

.paste-zone.is-focused{
  border-color:rgba(15,118,110,.72);
  background:rgba(15,118,110,.09);
  box-shadow:0 0 0 4px rgba(15,118,110,.12);
}

.paste-zone.is-uploading{
  border-color:rgba(201,134,46,.7);
  background:rgba(201,134,46,.1);
}

.entries-card{
  display:grid;
  gap:18px;
}

.entry-list{
  display:grid;
  gap:18px;
}

.entry-card{
  position:relative;
  display:grid;
  gap:14px;
  padding:20px;
  border-radius:24px;
  border:1px solid rgba(184,175,159,.55);
  background:
    linear-gradient(180deg, rgba(255,255,255,.9), rgba(248,243,235,.8));
  box-shadow:var(--shadow-soft);
}

.entry-card.status-open{
  border-color:#efcc8b;
}

.entry-card.status-done{
  border-color:#bfe0c9;
}

.entry-card.status-skipped{
  border-color:#cfc5b7;
}

.entry-anchor{
  position:absolute;
  top:-90px;
}

.insert-here{
  display:flex;
  justify-content:flex-end;
}

.btn-insert.active{
  background:linear-gradient(180deg, var(--primary), var(--primary-strong));
  color:#fff;
  border-color:transparent;
}

.entry-card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
}

.entry-card-title-wrap{
  display:grid;
  gap:10px;
}

.step-badge{
  display:inline-flex;
  align-items:center;
  width:max-content;
  padding:8px 12px;
  border-radius:999px;
  background:#ece7de;
  color:var(--text-muted);
  font-size:.82rem;
  font-weight:700;
}

.entry-card h3{
  font-size:1.3rem;
  letter-spacing:-0.03em;
}

.entry-head-actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.entry-meta{
  color:var(--text-muted);
  font-size:.95rem;
}

.entry-image-wrap{
  border-radius:20px;
  overflow:hidden;
  border:1px solid rgba(184,175,159,.45);
  background:#efe9df;
}

.entry-image-wrap img{
  width:100%;
  object-fit:contain;
}

.entry-body{
  display:grid;
  gap:14px;
}

.entry-text{
  line-height:1.72;
  font-size:1rem;
}

.code-block{
  border-radius:18px;
  overflow:hidden;
  border:1px solid rgba(21,56,51,.14);
  background:#132622;
  color:#ebf7f4;
}

.code-block-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 14px;
  border-bottom:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.04);
  color:#9fd2cb;
  font-size:.82rem;
  letter-spacing:.12em;
  text-transform:uppercase;
}

.code-block .btn-ghost{
  color:#dff6f2;
  border-color:rgba(255,255,255,.16);
}

.code-block pre{
  margin:0;
  padding:16px 18px;
  overflow:auto;
}

.code-block code{
  font-family:var(--font-mono);
  font-size:.93rem;
  line-height:1.65;
}

.code-block-compact pre{
  padding:14px 16px;
}

.comments-list{
  display:grid;
  gap:10px;
}

.comment{
  display:grid;
  gap:10px;
  padding:14px;
  border-radius:18px;
  border:1px solid rgba(184,175,159,.45);
  background:#fbf8f2;
}

.comment-meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  color:var(--text-muted);
  font-size:.84rem;
}

.comment-meta-actions{
  display:flex;
  align-items:center;
  gap:8px;
}

.comment-text{
  line-height:1.65;
}

.comment-del{
  width:34px;
  height:34px;
  border:none;
  border-radius:50%;
  background:#efe4dd;
  color:#7b1c18;
}

.comments-add{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:10px;
}

.entry-footer-grid{
  display:grid;
  grid-template-columns:minmax(0,260px) minmax(0,1fr);
  gap:14px;
  align-items:start;
}

.status-switch{
  display:grid;
  gap:10px;
}

.status-btn{
  text-align:left;
  padding:12px 14px;
  border-radius:16px;
  border:1px solid var(--border);
  background:#fbf8f2;
}

.status-btn.active{
  border-color:rgba(15,118,110,.38);
  background:rgba(15,118,110,.09);
  color:var(--primary-strong);
  font-weight:700;
}

.status-note{
  padding:14px;
  border-radius:16px;
  background:#f2ece3;
  border:1px solid rgba(184,175,159,.42);
  line-height:1.5;
}

.run-note-box{
  display:grid;
  gap:8px;
  padding:14px;
  border-radius:18px;
  background:#f9f5ee;
  border:1px solid rgba(184,175,159,.42);
}

.run-note-box textarea{
  min-height:100px;
}

.entry-card-placeholder{
  min-height:180px;
  align-items:center;
}

.entry-placeholder-box{
  height:110px;
  border-radius:18px;
  background:
    linear-gradient(90deg, rgba(15,118,110,.06) 25%, rgba(15,118,110,.12) 37%, rgba(15,118,110,.06) 63%);
  background-size:400% 100%;
  animation:shimmer 1.2s ease-in-out infinite;
}

.toast{
  position:fixed;
  left:50%;
  bottom:24px;
  transform:translateX(-50%) translateY(12px);
  background:#153833;
  color:#f4fbfa;
  border-radius:999px;
  padding:12px 18px;
  box-shadow:0 16px 36px rgba(21,56,51,.28);
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease, transform .2s ease;
  z-index:100;
}

.toast.is-visible{
  opacity:1;
  transform:translateX(-50%) translateY(0);
}

.modal{
  position:fixed;
  inset:0;
  z-index:120;
  display:grid;
  place-items:center;
  padding:24px;
}

.modal[hidden]{
  display:none;
}

.modal-backdrop{
  position:absolute;
  inset:0;
  background:rgba(21,56,51,.32);
  backdrop-filter:blur(4px);
}

.modal-panel{
  position:relative;
  width:min(720px, 100%);
  z-index:1;
}

.modal-panel p{
  margin-top:12px;
  line-height:1.6;
}

.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
}

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

.auth-shell{
  width:min(1180px, 100%);
  display:grid;
  grid-template-columns:minmax(0,1.15fr) minmax(340px,.85fr);
  gap:20px;
}

.auth-panel--brand{
  background:
    linear-gradient(160deg, rgba(15,118,110,.86), rgba(11,90,85,.92)),
    linear-gradient(320deg, rgba(201,134,46,.32), rgba(201,134,46,0));
  color:#f5fffd;
}

.auth-panel--brand .brand-kicker,
.auth-panel--brand p{
  color:rgba(245,255,253,.82);
}

.auth-panel--brand h1{
  margin-top:12px;
  font-size:clamp(2.4rem, 3vw, 3.6rem);
  line-height:.98;
  letter-spacing:-0.05em;
  max-width:10ch;
}

.auth-panel--brand p{
  margin-top:18px;
  max-width:52ch;
  line-height:1.7;
}

.auth-feature-list{
  display:grid;
  gap:14px;
  margin-top:30px;
}

.auth-feature-card{
  display:grid;
  gap:6px;
  padding:16px 18px;
  border-radius:20px;
  background:rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.16);
}

.auth-feature-card span{
  color:rgba(245,255,253,.78);
}

.auth-panel--form{
  align-self:stretch;
}

.auth-panel--form p{
  margin-top:10px;
  line-height:1.6;
}

.auth-form{
  display:grid;
  gap:16px;
  margin-top:18px;
}

.alert{
  margin-top:16px;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid transparent;
}

.alert-error{
  background:#f6e2de;
  border-color:#ebc0b7;
  color:#7b1c18;
}

@keyframes shimmer{
  0%{background-position:200% 0}
  100%{background-position:-200% 0}
}

@media (max-width: 1180px){
  .hero-grid,
  .workspace-grid,
  .auth-shell{
    grid-template-columns:1fr;
  }

  .workspace-sidebar{
    position:static;
  }
}

@media (max-width: 840px){
  .page-shell{
    padding:20px 16px 40px;
  }

  .stats-grid,
  .two-col,
  .entry-footer-grid{
    grid-template-columns:1fr;
  }

  .topbar,
  .library-head,
  .card-head,
  .doc-card-footer,
  .entry-card-head{
    flex-direction:column;
    align-items:flex-start;
  }

  .entry-head-actions,
  .topbar-actions{
    justify-content:flex-start;
  }

  .comments-add{
    grid-template-columns:1fr;
  }
}

@media (max-width: 540px){
  .create-card,
  .card,
  .hero-card,
  .auth-panel,
  .modal-panel{
    padding:18px;
    border-radius:22px;
  }

  .topbar h1{
    font-size:1.8rem;
  }

  .hero-copy h2{
    font-size:1.7rem;
  }

  .entry-card h3{
    font-size:1.1rem;
  }
}
