:root {
  --ink: #17221e;
  --forest: #17241f;
  --forest-2: #25332d;
  --green: #2d7a56;
  --green-soft: #e2eee7;
  --paper: #f4f1e9;
  --card: #fbfaf6;
  --white: #ffffff;
  --muted: #748078;
  --line: #dcded8;
  --warning: #b8583d;
  --shadow: 0 18px 45px rgba(26, 39, 33, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar {
  background: var(--forest);
  color: #f0f3ee;
  padding: 26px 20px 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; padding: 2px 6px 24px; border-bottom: 1px solid rgba(255,255,255,.09); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--green); color: white; font-family: Georgia, serif; font-weight: 700; font-size: 18px; }
.brand strong { display: block; font-family: Georgia, serif; font-size: 18px; letter-spacing: .02em; }
.brand small { display: block; font-size: 9px; letter-spacing: .17em; opacity: .52; margin-top: 3px; }
.sidebar-section { margin-top: 27px; }
.clients-section { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.eyebrow { font-size: 10px; letter-spacing: .16em; color: #8e9992; font-weight: 700; }
.eyebrow.green { color: var(--green); }
.nav-item { width: 100%; border: 0; background: transparent; color: #dce2dd; display: flex; align-items: center; gap: 11px; text-align: left; padding: 11px; border-radius: 10px; margin-top: 8px; cursor: pointer; }
.nav-item.active, .nav-item:hover { background: rgba(255,255,255,.09); }
.nav-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--green); font-family: Georgia, serif; }
.nav-item strong, .nav-item small { display: block; }
.nav-item strong { font-size: 14px; }
.nav-item small { font-size: 11px; color: #839088; margin-top: 2px; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 7px; }
.icon-button { width: 27px; height: 27px; border-radius: 7px; border: 0; cursor: pointer; font-size: 18px; }
.icon-button.subtle { color: #aab4ae; background: rgba(255,255,255,.07); }
.client-nav { margin-top: 9px; overflow: auto; }
.client-nav-item { width: 100%; border: 0; background: transparent; color: #bdc6c0; display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 9px; cursor: pointer; text-align: left; }
.client-nav-item:hover, .client-nav-item.active { background: rgba(255,255,255,.08); color: white; }
.client-nav-item > span { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 7px; background: var(--forest-2); font-size: 10px; font-weight: 800; }
.client-nav-item strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer { border: 1px solid rgba(255,255,255,.13); border-radius: 10px; padding: 13px; display: flex; gap: 9px; align-items: flex-start; }
.sidebar-footer strong, .sidebar-footer small { display: block; }
.sidebar-footer strong { font-size: 11px; }
.sidebar-footer small { color: #7f8d84; font-size: 10px; margin-top: 3px; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #63c192; flex: 0 0 auto; margin-top: 3px; }

.main { min-width: 0; }
.topbar { min-height: 112px; display: flex; justify-content: space-between; align-items: center; gap: 30px; padding: 25px 42px; border-bottom: 1px solid rgba(54,71,62,.1); background: rgba(250,248,242,.72); backdrop-filter: blur(12px); }
.topbar h1 { margin: 6px 0 0; font-family: Georgia, serif; font-size: clamp(28px, 3vw, 39px); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.save-state { color: var(--muted); font-size: 12px; min-width: 80px; text-align: right; }
.button { border: 1px solid transparent; border-radius: 9px; padding: 10px 15px; font-weight: 700; font-size: 13px; cursor: pointer; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--green); color: white; box-shadow: 0 7px 18px rgba(45,122,86,.18); }
.button.secondary { background: var(--card); border-color: var(--line); }
.button.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.button.large { padding: 13px 20px; }
.button.full { width: 100%; padding: 13px; }
.view { padding: 34px 42px 55px; }
.hero-card { min-height: 285px; border-radius: 18px; padding: 42px; color: white; background: radial-gradient(circle at 82% 15%, rgba(88,157,120,.46), transparent 29%), linear-gradient(135deg, #1c2c25, #243d31); display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; box-shadow: var(--shadow); }
.hero-card h2 { font-family: Georgia, serif; font-weight: 500; font-size: clamp(31px, 4vw, 50px); line-height: 1.05; margin: 20px 0 14px; }
.hero-card p { color: #becbc3; line-height: 1.55; max-width: 680px; margin: 0; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 9px; background: var(--green-soft); color: var(--green); font-size: 9px; letter-spacing: .14em; font-weight: 800; }
.hero-card .pill { background: rgba(107,193,148,.14); color: #8fd2ac; }
.section-header { display: flex; justify-content: space-between; margin: 35px 0 16px; }
.section-header h2 { margin: 0; font-family: Georgia, serif; font-size: 27px; font-weight: 500; }
.section-header p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 15px; }
.client-card { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 19px; text-align: left; cursor: pointer; min-height: 185px; transition: .2s ease; }
.client-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #bbc7bf; }
.client-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.client-avatar { width: 39px; height: 39px; border-radius: 10px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.arrow { color: #8b958f; }
.client-card h3 { margin: 22px 0 5px; font-family: Georgia, serif; font-size: 20px; }
.client-card p { color: var(--muted); margin: 0; font-size: 12px; }
.client-card-meta { margin-top: 24px; padding-top: 13px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: #89928c; font-size: 10px; }
.client-card-meta span { display: flex; align-items: center; gap: 5px; }
.empty-state { border: 1px dashed #c7ccc6; border-radius: 15px; text-align: center; padding: 55px 20px; background: rgba(255,255,255,.35); }
.empty-icon { margin: 0 auto 14px; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--green); background: var(--green-soft); font-family: Georgia, serif; font-size: 20px; }
.empty-state h3 { font-family: Georgia, serif; font-size: 24px; margin: 0; }
.empty-state p { color: var(--muted); max-width: 460px; margin: 9px auto 20px; }

#workspace-view { padding: 0; height: calc(100vh - 112px); overflow: hidden; }
.workspace-layout { height: 100%; display: grid; grid-template-columns: 245px minmax(420px, 1fr) 255px; }
.file-panel, .context-panel { background: rgba(251,250,246,.8); padding: 22px 18px; overflow: auto; }
.file-panel { border-right: 1px solid var(--line); }
.file-panel-header { padding: 4px 7px 18px; }
.file-panel-header strong { display: block; font-family: Georgia, serif; font-size: 16px; margin-top: 7px; }
.file-group { margin-bottom: 20px; }
.file-group > span { display: block; color: #a0a8a2; font-size: 9px; letter-spacing: .13em; font-weight: 800; padding: 0 9px 6px; }
.file-item { width: 100%; display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 8px 9px; border-radius: 7px; text-align: left; color: #667069; cursor: pointer; font-size: 12px; }
.file-item:hover, .file-item.active { color: var(--ink); background: #e8ece7; }
.file-item i { font-style: normal; font-family: Georgia, serif; color: var(--green); font-weight: 700; }
.editor-panel { min-width: 0; display: flex; flex-direction: column; background: white; }
.editor-toolbar { height: 69px; padding: 13px 19px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.editor-toolbar strong { display: block; font-size: 14px; margin-top: 4px; }
.segmented { display: flex; padding: 3px; background: #eef0ec; border-radius: 8px; }
.segmented button { border: 0; background: transparent; padding: 6px 10px; border-radius: 6px; font-size: 11px; color: #778179; cursor: pointer; }
.segmented button.active { background: white; color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
#editor { width: 100%; flex: 1; resize: none; border: 0; outline: 0; padding: 30px 36px 70px; font-family: "SFMono-Regular", Consolas, monospace; line-height: 1.65; font-size: 13px; color: #26342d; }
.context-panel { border-left: 1px solid var(--line); }
.context-score { display: flex; align-items: baseline; justify-content: space-between; margin-top: 14px; }
.context-score span { font-family: Georgia, serif; font-size: 18px; }
.context-score strong { font-size: 19px; color: var(--green); }
.progress { height: 6px; margin: 10px 0 13px; background: #e1e5e0; border-radius: 10px; overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .3s; }
.context-panel > p, .notice p { color: var(--muted); font-size: 11px; line-height: 1.55; }
.divider { height: 1px; background: var(--line); margin: 24px 0; }
.fact-row { display: flex; justify-content: space-between; font-size: 11px; margin-top: 12px; }
.fact-row span { color: var(--muted); }
.notice { margin-top: 25px; border: 1px solid #e3c7b9; background: #fff7f2; border-radius: 9px; padding: 12px; }
.notice strong { font-size: 11px; color: #8f4e38; }
.notice p { margin: 5px 0 0; color: #986b5b; }

.login-page { min-height: 100vh; background: radial-gradient(circle at 78% 12%, rgba(71,137,101,.28), transparent 27%), var(--forest); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); padding: 38px; border-radius: 18px; background: var(--card); box-shadow: 0 28px 70px rgba(0,0,0,.28); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { font-family: Georgia, serif; font-size: 20px; }
.login-brand small { margin-top: 3px; color: var(--muted); font-size: 9px; letter-spacing: .16em; }
.login-card h1 { margin: 18px 0 8px; font-family: Georgia, serif; font-size: 38px; font-weight: 500; }
.login-card > p { margin: 0 0 25px; color: var(--muted); }
.login-card label { display: block; margin: 15px 0; font-size: 12px; font-weight: 700; }
.login-card input { width: 100%; margin-top: 7px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 9px; background: white; outline: none; }
.login-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(45,122,86,.12); }
.login-card .form-error { min-height: 22px; margin: 4px 0 8px; color: var(--warning); font-size: 12px; }
.login-note { display: block; margin-top: 18px; color: var(--muted); text-align: center; }

.markdown-preview { padding: 32px 44px 80px; overflow: auto; line-height: 1.65; }
.markdown-preview > * { max-width: 780px; }
.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 { font-family: Georgia, serif; font-weight: 500; line-height: 1.2; }
.markdown-preview h1 { font-size: 35px; margin: 10px 0 27px; }
.markdown-preview h2 { font-size: 24px; margin: 34px 0 12px; padding-top: 11px; border-top: 1px solid #e8e9e4; }
.markdown-preview h3 { font-size: 18px; margin: 24px 0 9px; }
.markdown-preview p, .markdown-preview li { color: #4d5952; font-size: 14px; }
.markdown-preview code { background: #edf1ed; color: #245c43; border-radius: 4px; padding: 2px 5px; }
.markdown-preview blockquote { border-left: 3px solid var(--green); padding: 9px 17px; margin-left: 0; color: #435249; background: #f1f6f2; }
.markdown-preview table { width: 100%; border-collapse: collapse; margin: 17px 0; font-size: 12px; }
.markdown-preview th, .markdown-preview td { text-align: left; border: 1px solid var(--line); padding: 8px 10px; }
.markdown-preview th { background: #f2f4f0; }

dialog { border: 0; border-radius: 17px; padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: 0 30px 100px rgba(16,30,24,.28); }
dialog::backdrop { background: rgba(15,26,21,.6); backdrop-filter: blur(4px); }
dialog form, .share-dialog-content { position: relative; padding: 35px; background: var(--card); }
dialog h2 { font-family: Georgia, serif; font-size: 32px; font-weight: 500; margin: 17px 0 7px; }
dialog p { color: var(--muted); line-height: 1.5; font-size: 13px; }
.dialog-close { position: absolute; right: 17px; top: 16px; width: 30px; height: 30px; border-radius: 8px; border: 0; background: #eceee9; cursor: pointer; font-size: 21px; }
label { display: block; font-size: 12px; font-weight: 700; margin: 21px 0 0; }
label span { color: #9da49f; font-weight: 400; }
input { width: 100%; border: 1px solid #ced3cd; border-radius: 8px; background: white; padding: 12px; margin-top: 7px; outline: none; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(45,122,86,.1); }
.form-error { min-height: 30px; padding-top: 9px; color: var(--warning); font-size: 11px; }
.share-field { display: flex; gap: 7px; margin: 20px 0 11px; }
.share-field input { margin: 0; font-size: 11px; }

.share-page { background: #f7f5ef; }
.share-header { height: 78px; padding: 15px 32px; display: flex; align-items: center; justify-content: space-between; background: var(--forest); color: white; }
.share-header .brand { border: 0; padding: 0; }
.share-main { max-width: 1200px; margin: 0 auto; padding: 55px 30px 90px; }
.share-intro h1 { font-family: Georgia, serif; font-weight: 500; font-size: 46px; margin: 9px 0 8px; }
.share-intro p { color: var(--muted); }
.share-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); margin-top: 38px; min-height: 600px; background: white; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; box-shadow: var(--shadow); }
.share-files { padding: 18px; background: #f0f1ed; border-right: 1px solid var(--line); }
.share-files button { width: 100%; border: 0; background: transparent; padding: 9px; display: flex; gap: 8px; border-radius: 7px; text-align: left; font-size: 11px; color: #68736b; cursor: pointer; }
.share-files button:hover, .share-files button.active { background: white; color: var(--ink); }
.share-files button span { color: var(--green); font-family: Georgia, serif; }
.share-content { max-height: 75vh; }
.share-error { margin-top: 30px; padding: 30px; border-radius: 12px; background: #fff0ea; color: var(--warning); }

@media (max-width: 1080px) {
  .workspace-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .context-panel { display: none; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { min-height: auto; padding: 15px; }
  .sidebar-section, .sidebar-footer { display: none; }
  .brand { border: 0; padding: 0; }
  .topbar { padding: 20px; align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .view { padding: 22px 18px 40px; }
  .hero-card { padding: 28px; min-height: 360px; flex-direction: column; align-items: flex-start; }
  #workspace-view { height: auto; }
  .workspace-layout { display: block; }
  .file-panel { border: 0; max-height: 270px; }
  .editor-panel { min-height: 70vh; }
  #editor { min-height: 65vh; padding: 25px 20px; }
  .share-layout { display: block; }
  .share-files { border-right: 0; border-bottom: 1px solid var(--line); max-height: 230px; overflow: auto; }
}
