:root {
  --ink: #17251f;
  --ink-soft: #5f6962;
  --forest: #173f35;
  --forest-light: #245b4a;
  --cream: #f5f1e8;
  --paper: #fffdf8;
  --line: #ddd7ca;
  --line-dark: #cbc2b2;
  --apricot: #ef9a69;
  --sage: #b8cabb;
  --gold: #d5b764;
  --danger: #a64a3d;
  --shadow: 0 24px 70px rgba(28, 48, 39, .14);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; min-height: 100vh; background: var(--cream); color: var(--ink); font-family: var(--sans); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.is-hidden { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; position: relative; overflow: hidden; padding: 32px; background: var(--forest); }
.login-view::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 20% 20%, rgba(239,154,105,.22), transparent 28%), linear-gradient(135deg, transparent 0 48%, rgba(255,255,255,.025) 48% 49%, transparent 49%); background-size: auto, 38px 38px; }
.login-orbit { position: absolute; border: 1px solid rgba(255,255,255,.11); border-radius: 50%; }
.orbit-one { width: 720px; height: 720px; left: -330px; bottom: -430px; }
.orbit-two { width: 460px; height: 460px; right: -140px; top: -210px; }
.login-card { position: relative; width: min(620px, 100%); background: var(--paper); border-radius: 4px 64px 4px 4px; padding: clamp(36px, 7vw, 76px); box-shadow: 0 40px 110px rgba(4,20,14,.4); }
.login-card::after { content: ""; position: absolute; width: 78px; height: 7px; background: var(--apricot); left: 0; top: 0; }
.brand-lockup { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-glyph { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px 4px 12px 4px; color: var(--paper); background: var(--forest); font: italic 700 21px var(--serif); }
.brand-lockup strong, .brand-lockup small { display: block; line-height: 1.05; }
.brand-lockup strong { font: 600 17px var(--serif); }
.brand-lockup small { margin-top: 3px; color: var(--ink-soft); font: 600 9px var(--sans); text-transform: uppercase; letter-spacing: .15em; }
.brand-lockup-large .brand-glyph { width: 44px; height: 44px; font-size: 25px; }
.brand-lockup-large strong { font-size: 21px; }
.kicker, .scope-eyebrow { color: var(--forest-light); font-size: 10px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.login-card .kicker { margin-top: 56px; }
.login-card h1 { margin: 14px 0 22px; font: 500 clamp(40px, 7vw, 60px)/.98 var(--serif); letter-spacing: -.035em; }
.login-card h1 em { color: var(--forest-light); font-weight: 400; }
.login-copy { max-width: 480px; color: var(--ink-soft); line-height: 1.65; }
.slack-button { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 32px; width: 100%; min-height: 56px; border-radius: 14px; background: var(--forest); color: white; font-weight: 750; text-decoration: none; box-shadow: 0 12px 24px rgba(23,63,53,.18); transition: transform .2s, background .2s; }
.slack-button:hover { background: var(--forest-light); transform: translateY(-2px); }
.slack-symbol { color: var(--gold); font-size: 24px; }
.login-note { text-align: center; margin: 15px 0 0; color: #899088; font-size: 11px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 18px 18px; border-right: 1px solid var(--line); background: #eee9df; z-index: 10; }
.sidebar > .brand-lockup { padding: 0 10px 28px; }
.primary-nav { display: grid; gap: 5px; }
.nav-item { display: grid; grid-template-columns: 23px 1fr auto; align-items: center; width: 100%; border: 0; border-radius: 10px; background: transparent; padding: 11px 12px; text-align: left; color: #55625b; cursor: pointer; font-size: 13px; font-weight: 650; }
.nav-item span { font-size: 17px; }
.nav-item b { display: grid; place-items: center; min-width: 21px; height: 21px; padding: 0 6px; border-radius: 10px; background: #ded8cc; font-size: 10px; }
.nav-item:hover { background: rgba(255,255,255,.48); }
.nav-item.is-active { color: var(--paper); background: var(--forest); box-shadow: 0 10px 24px rgba(23,63,53,.14); }
.nav-item.is-active b { background: rgba(255,255,255,.15); }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; margin: 30px 10px 10px; color: #8a8f89; text-transform: uppercase; letter-spacing: .14em; font-size: 9px; font-weight: 800; }
.sidebar-heading button { border: 0; background: transparent; color: #767f78; cursor: pointer; font-size: 15px; }
.space-list { overflow: auto; min-height: 0; padding-right: 3px; }
.space-group { margin-bottom: 10px; }
.space-label { display: flex; gap: 9px; align-items: center; padding: 8px 10px 5px; color: var(--ink); font: 650 13px var(--serif); }
.space-label i { width: 8px; height: 8px; border: 2px solid var(--apricot); border-radius: 50%; }
.space-group[data-space="personal"] .space-label i { border-color: var(--gold); }
.scope-button { position: relative; display: block; width: 100%; padding: 8px 10px 8px 27px; border: 0; border-radius: 8px; background: transparent; color: #68716b; text-align: left; font-size: 12px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scope-button:hover { color: var(--ink); background: rgba(255,255,255,.45); }
.scope-button.is-active { color: var(--forest); background: #fbf8f1; font-weight: 750; }
.scope-button.is-active::before { content: ""; position: absolute; left: 10px; top: 50%; width: 6px; height: 6px; transform: translateY(-50%); border-radius: 50%; background: var(--apricot); }
.scope-mode { float: right; opacity: .55; font-size: 9px; text-transform: uppercase; }
.sidebar-footer { display: grid; grid-template-columns: 38px 1fr 28px; gap: 10px; align-items: center; margin-top: auto; padding: 17px 8px 2px; border-top: 1px solid var(--line); }
.user-avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--sage); color: var(--forest); font: 750 11px var(--sans); }
.user-copy { min-width: 0; }
.user-copy strong, .user-copy small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-copy strong { font-size: 12px; }
.user-copy small { color: #899088; margin-top: 3px; font-size: 9px; }
.quiet-icon { display: grid; place-items: center; border: 0; background: transparent; color: #727b74; text-decoration: none; cursor: pointer; font-size: 19px; }

.workspace { min-width: 0; background: var(--cream); }
.topbar { height: 76px; display: flex; align-items: center; gap: 18px; padding: 0 34px; border-bottom: 1px solid var(--line); background: rgba(245,241,232,.9); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 8; }
.search-box { width: min(560px, 48vw); display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; background: #ebe6dc; border: 1px solid transparent; border-radius: 12px; padding: 9px 12px; transition: background .2s, border .2s; }
.search-box:focus-within { background: var(--paper); border-color: var(--line-dark); }
.search-box span { color: #7b837e; font-size: 18px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
kbd { border: 1px solid #d5cec0; border-radius: 5px; padding: 2px 6px; background: #f8f5ef; color: #91958f; font: 9px var(--sans); }
.top-actions { margin-left: auto; display: flex; gap: 9px; }
.button { display: inline-flex; gap: 7px; align-items: center; justify-content: center; min-height: 38px; border-radius: 10px; border: 1px solid var(--line-dark); padding: 0 14px; background: var(--paper); color: var(--ink); font-size: 11px; font-weight: 750; cursor: pointer; text-decoration: none; transition: transform .15s, box-shadow .15s; }
.button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(24,43,34,.09); }
.button-dark { background: var(--forest); border-color: var(--forest); color: white; }
.button-danger { border-color: #d7aaa2; color: var(--danger); background: #fff8f6; }
.button-ghost { background: transparent; }
.button-small { min-height: 32px; padding: 0 12px; font-size: 10px; }
.mobile-menu { display: none; border: 0; background: transparent; font-size: 20px; }
.content-stage { padding: 34px clamp(24px, 4vw, 56px) 64px; }
.hero { display: flex; align-items: end; justify-content: space-between; min-height: 188px; gap: 28px; padding: 36px clamp(28px, 4vw, 52px); border-radius: 3px 38px 3px 3px; color: #f7f3ea; background: var(--forest); position: relative; overflow: hidden; }
.hero::before { content: "J"; position: absolute; right: 35%; bottom: -84px; color: rgba(255,255,255,.035); font: italic 230px var(--serif); }
.hero::after { content: ""; position: absolute; right: -80px; top: -120px; width: 300px; height: 300px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 44px rgba(255,255,255,.025), 0 0 0 88px rgba(255,255,255,.018); }
.hero > * { position: relative; z-index: 1; }
.hero .scope-eyebrow { color: #d9c477; }
.hero h1 { margin: 10px 0 8px; font: 500 clamp(34px, 5vw, 52px)/1 var(--serif); letter-spacing: -.035em; }
.hero p:last-child { margin: 0; max-width: 600px; color: #bfcac3; font-size: 13px; line-height: 1.6; }
.hero-stats { display: flex; gap: 38px; padding-right: 12px; }
.hero-stats div { min-width: 78px; }
.hero-stats strong, .hero-stats span { display: block; }
.hero-stats strong { font: 500 32px var(--serif); }
.hero-stats span { color: #aebdb5; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; margin-top: 4px; }
.section-toolbar { display: flex; align-items: center; justify-content: space-between; margin: 34px 0 17px; }
.view-heading { display: flex; align-items: baseline; gap: 12px; }
.view-heading h2 { margin: 0; font: 600 20px var(--serif); }
.view-heading span { color: #8b908a; font-size: 10px; }
.segmented { display: flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.segmented button { width: 31px; height: 27px; border: 0; border-radius: 6px; background: transparent; color: #8c918c; cursor: pointer; }
.segmented button.is-active { background: var(--paper); color: var(--forest); box-shadow: 0 2px 7px rgba(32,45,38,.1); }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.card-grid.list-layout { grid-template-columns: 1fr; }
.entry-card { min-height: 196px; display: flex; flex-direction: column; padding: 22px; border: 1px solid var(--line); border-radius: 3px 20px 3px 3px; background: rgba(255,253,248,.77); cursor: pointer; transition: transform .2s, border .2s, box-shadow .2s; overflow: hidden; position: relative; }
.entry-card::before { content: ""; width: 5px; height: 36px; position: absolute; left: 0; top: 23px; background: var(--sage); }
.entry-card[data-type*="Decision"]::before { background: var(--apricot); }
.entry-card[data-scope*="personal"]::before { background: var(--gold); }
.entry-card:hover { transform: translateY(-3px); border-color: #c8c1b4; box-shadow: 0 18px 38px rgba(40,55,48,.1); }
.entry-card-head { display: flex; justify-content: space-between; gap: 10px; color: #8a908b; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
.status-pill { border-radius: 20px; padding: 3px 7px; color: var(--forest); background: #e2ece4; letter-spacing: .06em; }
.status-pill.draft { color: #835f28; background: #f1e5c1; }
.entry-card h3 { margin: 18px 0 8px; font: 600 20px/1.18 var(--serif); }
.entry-card p { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.entry-card footer { margin-top: auto; padding-top: 18px; display: flex; justify-content: space-between; gap: 12px; color: #8b908c; font-size: 9px; }
.entry-card footer span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-grid.list-layout .entry-card { min-height: 104px; display: grid; grid-template-columns: 1fr 2fr; column-gap: 20px; }
.card-grid.list-layout .entry-card p { margin-top: 18px; }
.card-grid.list-layout .entry-card footer { grid-column: 1 / -1; }
.proposal-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.proposal-card { padding: 21px; border-radius: 16px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; }
.proposal-card header { display: flex; justify-content: space-between; gap: 8px; }
.proposal-card h3 { margin: 20px 0 9px; font: 600 19px var(--serif); }
.proposal-card p { color: var(--ink-soft); font-size: 11px; line-height: 1.55; min-height: 52px; }
.proposal-card footer { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; color: #8a908b; font-size: 9px; }
.proposal-state { padding: 4px 8px; border-radius: 20px; background: #e1ece5; color: var(--forest); font-size: 9px; font-weight: 750; text-transform: uppercase; }
.proposal-state.revoked { color: #755a55; background: #e9dfdb; }
.proposal-state.publish_failed { color: var(--danger); background: #f3deda; }
.connections-view { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.connection-card { min-height: 250px; padding: 24px; border: 1px solid var(--line); background: var(--paper); border-radius: 3px 22px 3px 3px; }
.connection-card .connection-icon { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 14px; color: white; background: var(--forest); font: 600 18px var(--serif); }
.connection-card h3 { margin: 24px 0 8px; font: 600 21px var(--serif); }
.connection-card p { color: var(--ink-soft); font-size: 11px; line-height: 1.6; }
.connection-card code { display: block; margin-top: 18px; padding: 11px; border-radius: 8px; background: #eeeae1; font-size: 9px; overflow: hidden; text-overflow: ellipsis; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--ink-soft); }
.empty-state span { color: var(--apricot); font-size: 32px; }
.empty-state h3 { margin: 14px 0 6px; color: var(--ink); font: 600 24px var(--serif); }
.empty-state p { font-size: 12px; }

.reader { position: fixed; inset: 0 0 0 auto; width: min(700px, calc(100vw - 260px)); background: var(--paper); border-left: 1px solid var(--line); box-shadow: -30px 0 80px rgba(27,45,37,.18); z-index: 20; animation: slide-in .26s ease-out; }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.reader-toolbar { height: 68px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.reader-actions { display: flex; align-items: center; gap: 10px; }
.reader-body { height: calc(100vh - 68px); overflow: auto; padding: 46px clamp(30px, 7vw, 74px) 90px; }
.reader-body h1 { margin: 12px 0 12px; font: 500 clamp(38px, 6vw, 58px)/1 var(--serif); letter-spacing: -.035em; }
.reader-description { color: var(--ink-soft); font: 17px/1.55 var(--serif); }
.metadata-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 24px 0 36px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.metadata-row span { border: 1px solid var(--line); border-radius: 20px; padding: 5px 9px; color: #68726b; font-size: 9px; }
.markdown-body { font: 16px/1.72 var(--serif); color: #28352f; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { color: var(--ink); line-height: 1.15; }
.markdown-body h1 { font-size: 34px; }
.markdown-body h2 { margin-top: 2em; font-size: 25px; }
.markdown-body h3 { margin-top: 1.7em; font-size: 19px; }
.markdown-body pre { overflow: auto; padding: 18px; border-radius: 10px; background: #eeeae1; font: 12px/1.6 ui-monospace, monospace; }
.markdown-body code { background: #eeeae1; border-radius: 4px; padding: 2px 4px; font: .82em ui-monospace, monospace; }
.markdown-body blockquote { margin-left: 0; padding-left: 18px; border-left: 3px solid var(--apricot); color: var(--ink-soft); }
.markdown-body a { color: var(--forest-light); }
.markdown-body table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 12px; }
.markdown-body th, .markdown-body td { padding: 9px; border: 1px solid var(--line); text-align: left; }

.modal { width: min(780px, calc(100vw - 32px)); max-height: calc(100vh - 36px); padding: 0; border: 0; border-radius: 4px 30px 4px 4px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(15,31,24,.56); backdrop-filter: blur(4px); }
.modal form { max-height: calc(100vh - 36px); overflow: auto; padding: 31px; }
.modal-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 24px; }
.modal-header h2 { margin: 7px 0 0; font: 600 31px var(--serif); }
.modal-intro { color: var(--ink-soft); margin: -10px 0 24px; font-size: 12px; line-height: 1.55; }
.modal label { display: block; margin: 15px 0; color: #56615b; font-size: 10px; font-weight: 750; }
.modal input, .modal textarea, .modal select { display: block; width: 100%; margin-top: 7px; border: 1px solid var(--line-dark); border-radius: 9px; outline: 0; padding: 10px 11px; background: #fbf9f4; color: var(--ink); font-size: 12px; resize: vertical; }
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: var(--forest-light); box-shadow: 0 0 0 3px rgba(36,91,74,.08); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.code-editor { min-height: 300px; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace !important; tab-size: 2; }
.modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.modal-footer > span { color: #878d87; font-size: 9px; }
.modal-actions { display: flex; gap: 8px; align-items: center; }
.optional { color: #999e99; font-weight: 400; }
.source-tabs, .config-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: #eee9df; }
.source-tabs button, .config-tabs button { flex: 1; min-height: 35px; border: 0; border-radius: 7px; background: transparent; color: #727a74; font-size: 10px; font-weight: 700; cursor: pointer; }
.source-tabs button.is-active, .config-tabs button.is-active { color: var(--forest); background: var(--paper); box-shadow: 0 3px 10px rgba(25,42,34,.08); }
.drop-zone { min-height: 170px; display: grid !important; place-items: center; align-content: center; gap: 5px; border: 1px dashed #bbb3a5; border-radius: 14px; background: #f7f3eb; cursor: pointer; text-align: center; }
.drop-zone.is-dragging { border-color: var(--forest); background: #edf2ec; }
.drop-zone input { display: none; }
.drop-zone strong { color: var(--ink); font-size: 13px; }
.drop-zone small { color: #8c918c; font-size: 9px; }
.drop-zone em { margin-top: 8px; color: var(--forest); font-style: normal; font-size: 10px; font-weight: 750; }
.drop-icon { color: var(--forest); font-size: 28px; }
.endpoint-box { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin: 22px 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: #f2eee6; font: 11px ui-monospace, monospace; }
.endpoint-box span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.endpoint-box button { border: 0; background: transparent; color: var(--forest); font: 750 10px var(--sans); cursor: pointer; }
.config-code { min-height: 130px; margin: 12px 0 0; overflow: auto; padding: 18px; border-radius: 10px; background: #16251f; color: #d8e1da; font: 11px/1.6 ui-monospace, monospace; white-space: pre-wrap; }
.connection-note { display: flex; gap: 10px; align-items: center; margin-top: 16px; color: var(--forest); }
.connection-note > span { font-size: 9px; }
.connection-note strong, .connection-note small { display: block; }
.connection-note strong { font-size: 10px; }
.connection-note small { margin-top: 3px; color: #878d87; font-size: 9px; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); z-index: 40; padding: 11px 16px; border-radius: 10px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 11px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.document-page { background: var(--paper); }
.standalone-document { width: min(760px, calc(100% - 40px)); margin: 0 auto; padding: 72px 0 120px; }
.standalone-document > h1 { font: 500 52px/1.02 var(--serif); }
.back-link { display: inline-block; margin-bottom: 38px; color: var(--forest-light); text-decoration: none; font-size: 11px; font-weight: 750; }

@media (max-width: 1100px) {
  .card-grid, .proposal-board, .connections-view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-stats { display: none; }
}
@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-105%); transition: transform .25s; box-shadow: var(--shadow); }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-menu { display: block; }
  .topbar { height: auto; min-height: 70px; flex-wrap: wrap; padding: 14px 18px; }
  .search-box { order: 3; width: 100%; }
  .top-actions { margin-left: auto; }
  #connect-button { display: none; }
  .content-stage { padding: 20px 16px 50px; }
  .hero { min-height: 170px; padding: 28px 25px; }
  .card-grid, .proposal-board, .connections-view { grid-template-columns: 1fr; }
  .reader { width: 100vw; }
  .field-pair { grid-template-columns: 1fr; gap: 0; }
  .modal form { padding: 24px 18px; }
  .modal-footer { align-items: stretch; flex-direction: column; }
  .login-view { padding: 16px; }
  .login-card { padding: 34px 25px; border-radius: 3px 36px 3px 3px; }
}
