:root {
  --paper: #faf8f5;
  --card: #ffffff;
  --ink: #1d1b26;
  --ink-2: #4a4553;
  --muted: #8a8494;
  --line: #e9e5df;
  --accent: #f0442c;
  --accent-2: #e2124f;
  --grad: linear-gradient(135deg, #ffb23e, #ff6a4d 55%, #f2346f);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(29, 27, 38, .05), 0 4px 14px rgba(29, 27, 38, .05);
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.02em; margin: 0; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 600; margin: 4px 0 10px; }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.break { word-break: break-all; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
td.row { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.narrow { max-width: 480px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }

/* forms */
label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; color: var(--ink-2); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #dcd7cf; border-radius: 9px; padding: 9px 11px; min-width: 0;
}
input[type=color] { padding: 2px; height: 38px; width: 64px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid #dcd7cf; background: #fff; color: var(--ink); font: 500 14px/1.2 inherit; font-family: inherit; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f4f1ec; text-decoration: none; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #34303f; }
.btn.danger { color: #c4122f; border-color: #f2c4cc; }
.btn.danger:hover { background: #fdecef; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 13px 22px; font-size: 16px; border-radius: 12px; }
.link { background: none; border: 0; padding: 0; color: var(--accent-2); font: inherit; cursor: pointer; }
.link.danger { color: #c4122f; }
form { margin: 0; }

/* shell */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 14px; padding: 18px 14px; border-right: 1px solid var(--line); background: #f5f2ed; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); font: 800 21px/1 var(--display); letter-spacing: -.04em; text-decoration: none !important; }
.org-switch { width: 100%; font-weight: 600; }
.side nav, .side-foot { display: flex; flex-direction: column; gap: 2px; }
.side nav a, .side-foot a, .side-foot .link { padding: 7px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; text-align: left; text-decoration: none; }
.side nav a:hover, .side-foot a:hover { background: #ebe7e0; }
.side nav a.on, .side-foot a.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }
.side-foot .link { color: var(--muted); }
.main { padding: 26px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; }
.impersonating { display: flex; justify-content: center; gap: 12px; padding: 8px; background: #2b1d4a; color: #fff; }
.impersonating .link { color: #ffb3c1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; background: #e7f6ec; color: #17633a; border: 1px solid #c7ead3; }
.flash.err { background: #fdecef; color: #a3122d; border-color: #f6c9d1; }
.callout { padding: 14px 16px; border-radius: var(--radius); background: #fff4ea; border: 1px solid #ffd9bd; margin-bottom: 16px; }
.empty { padding: 40px; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eeebe6; color: var(--ink-2); text-transform: capitalize; margin-left: 4px; vertical-align: 1px; }
.s-open { background: #ffe9e4; color: #c2361d; }
.s-in_progress { background: #fff2cc; color: #8a5a00; }
.s-resolved { background: #dcf5e5; color: #17633a; }
.s-closed { background: #ebe8e3; color: #6b6575; }
.p-low { background: #eef1f6; color: #4c5a72; }
.p-high { background: #ffe4d1; color: #a4410b; }
.p-urgent { background: #c4122f; color: #fff; }
.avatar { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 10px; font-weight: 700; flex: none; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: #ece8e2; }
.seg a { padding: 5px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; text-decoration: none; }
.seg a.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.tabs { margin-bottom: 16px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input[type=search] { flex: 1; min-width: 200px; max-width: 360px; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 16px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; background: #fbfaf8; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover td { background: #fcfbf9; }
.table tr.dim td { opacity: .6; }
.clamp1 { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* board */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #f1eee9; border-radius: 14px; padding: 10px; min-height: 300px; transition: background .15s, box-shadow .15s; }
.col.over { background: #ffe9e4; box-shadow: inset 0 0 0 2px var(--accent); }
.col h3 { font: 600 13px/1 Inter, sans-serif; letter-spacing: 0; display: flex; align-items: center; gap: 6px; padding: 4px 4px 10px; }
.col h3 .pill { margin: 0; }
.col-body { display: flex; flex-direction: column; gap: 10px; }
.fb-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; color: var(--ink); text-decoration: none !important; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; }
.fb-card:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(29, 27, 38, .1); }
.fb-card.dragging { opacity: .4; }
.fb-card img { display: block; width: 100%; height: 120px; object-fit: cover; object-position: top; border-bottom: 1px solid var(--line); background: #f3f1ed; }
.fb-body { padding: 10px 12px; }
.fb-top { display: flex; gap: 6px; align-items: center; font-size: 12px; }
.fb-top .muted { margin-left: auto; }
.clamp { margin: 6px 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fb-meta { display: flex; gap: 8px; align-items: center; font-size: 12px; }
.fb-meta span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.fb-comment { margin: 0 0 16px; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); font-size: 16px; white-space: pre-wrap; }
.shot { display: block; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); background: #fff; margin-bottom: 24px; }
.shot img { display: block; width: 100%; }
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.msg-head { display: flex; gap: 8px; align-items: center; }
.msg p { margin: 6px 0 0 32px; white-space: pre-wrap; }
.detail-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 20px; }
.detail-side .card + .card { margin-top: 0; }
.meta { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 8px 10px; margin: 0; font-size: 13px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; min-width: 0; }
details summary { cursor: pointer; font-weight: 600; }
.logs { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.logs li { padding: 6px 8px; border-radius: 6px; background: #fff8e1; word-break: break-word; }
.logs li.error { background: #fdecef; color: #a3122d; }

/* sites */
.site-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-bottom: 16px; }
.site-list .card { margin: 0; }
.site { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none !important; }
.site > div { flex: 1; min-width: 0; }
.swatch { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px #fff, 0 0 0 4px var(--line); }
.snippet { margin: 0; padding: 14px 16px; background: var(--ink); color: #ffd9cf; border-radius: 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-color: #f6c9d1; }
.danger-zone p { margin: 2px 0 0; }
.invite input[type=email] { flex: 1; min-width: 220px; }

/* admin */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; margin: 0 !important; }
.stat b { font: 800 30px/1.1 var(--display); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.bar { flex: 1; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--grad); }
.menu { position: relative; display: inline-block; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; width: 260px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 30px rgba(0, 0, 0, .12); text-align: left; }
.menu-body input { flex: 1; padding: 6px 8px; }

/* auth */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: radial-gradient(1200px 600px at 80% -10%, #ffe1d4, transparent), var(--paper); }
.auth-card { width: min(400px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 30px; box-shadow: 0 20px 60px rgba(29, 27, 38, .08); display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { font-size: 24px; }
.auth-card p { margin: 0; }

/* landing */
.land-nav { display: flex; justify-content: space-between; align-items: center; max-width: 1160px; margin: 0 auto; padding: 22px 24px; }
.land-nav nav { display: flex; gap: 18px; align-items: center; }
.land-nav nav a:not(.btn) { color: var(--ink-2); font-weight: 500; }
.hero { max-width: 1160px; margin: 0 auto; padding: 50px 24px 70px; display: grid; grid-template-columns: 1.05fr 1fr; gap: 50px; align-items: center; }
.hero h1 { font-size: clamp(40px, 6vw, 68px); line-height: 1; letter-spacing: -.045em; }
.circled { position: relative; white-space: nowrap; color: var(--accent-2); margin: 0 .22em 0 .08em; }
.circled::after { content: ""; position: absolute; inset: -10px -14px -8px -12px; border: 3px solid var(--ink); border-radius: 50% 46% 52% 48% / 60% 50% 55% 45%; transform: rotate(-3deg); }
.lede { font-size: 18px; color: var(--ink-2); max-width: 540px; margin: 22px 0; }
.hero-cta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.mock { background: #fff; border-radius: 16px; box-shadow: 0 30px 80px rgba(29, 27, 38, .16); overflow: hidden; transform: rotate(1.5deg); }
.mock-bar { display: flex; gap: 6px; padding: 12px 14px; background: #f1eee9; }
.mock-bar i { width: 10px; height: 10px; border-radius: 50%; background: #dcd7cf; }
.mock-body { position: relative; padding: 34px; height: 340px; }
.mock-h { height: 26px; width: 70%; border-radius: 6px; background: #ece8e2; }
.mock-p { height: 12px; width: 90%; border-radius: 6px; background: #f3f0eb; margin-top: 16px; }
.mock-p.short { width: 60%; }
.mock-btn { display: inline-block; margin-top: 34px; padding: 12px 38px 12px 22px; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 600; }
.mock-ring { position: absolute; left: 18px; top: 132px; width: 190px; height: 76px; border: 3px solid #ff2d55; border-radius: 50%; transform: rotate(-4deg); }
.mock-pin { position: absolute; left: 160px; top: 128px; animation: bob 2.4s ease-in-out infinite; }
.mock-note { position: absolute; right: 26px; bottom: 34px; max-width: 220px; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
@keyframes bob { 50% { transform: translateY(-6px); } }
.features { max-width: 1160px; margin: 0 auto; padding: 0 24px 80px; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.feature { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.feature h3 { font-size: 19px; margin-bottom: 6px; }
.feature p { margin: 0; color: var(--ink-2); }
.land-foot { text-align: center; padding: 30px; }
.legal { max-width: 760px; margin: 0 auto; padding: 20px 24px 40px; font-size: 15px; line-height: 1.65; color: var(--ink-2); }
.legal h1 { font-size: 40px; color: var(--ink); }
.legal h2 { font-size: 20px; color: var(--ink); margin: 32px 0 8px; }
.legal h3 { font-size: 16px; color: var(--ink); margin: 20px 0 6px; }
.legal ul { padding-left: 22px; }
.legal li { margin: 4px 0; }
.legal .caps { text-transform: uppercase; font-size: 13px; }
.legal .table { font-size: 14px; }
.legal .table td, .legal .table th { vertical-align: top; }
@media (max-width: 640px) { .legal .table { display: block; overflow-x: auto; } }

/* demo */
body.demo { background: #fffdf8; }
.demo-page { max-width: 980px; margin: 0 auto; padding: 50px 24px 120px; }
.demo-page h1 { font-size: 48px; }
.demo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin: 30px 0; }
.demo-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.demo-img { height: 160px; border-radius: 12px; margin-bottom: 12px; }
.d0 { background: linear-gradient(135deg, #c98b5a, #6b3b1f); }
.d1 { background: linear-gradient(135deg, #e3b26b, #8a4f1a); }
.d2 { background: linear-gradient(135deg, #a55d3c, #3d1e12); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin: 0; border: 0; padding: 0; flex-direction: row; flex-wrap: wrap; }
  .org-switch { width: auto; }
  .main { padding: 20px 16px 50px; }
  .detail { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .hero { grid-template-columns: 1fr; padding-top: 20px; }
  .board { grid-template-columns: repeat(4, 260px); }
  .table { display: block; overflow-x: auto; }
}

/* realtime */
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #cfc9c0; margin-left: auto; transition: background .3s; }
.live-dot.on { background: #22a35a; box-shadow: 0 0 0 3px rgba(34, 163, 90, .18); }
.live-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; margin-bottom: 16px; border-radius: 10px; background: #fff4ea; border: 1px solid #ffd9bd; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(340px, calc(100vw - 40px)); }
.toast { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: #fff; text-decoration: none !important; box-shadow: 0 12px 30px rgba(0, 0, 0, .25); animation: toast-in .2s ease-out; }
.toast span { color: #cfc9d6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
