/* ============================================================
   Group structure demo, styled after the current Welley group sidebar.
   Token values were measured on welley.social (theme-navy).
   ============================================================ */
:root {
  --bg-main: #f1f3f6;
  --bg-primary: #ffffff;
  --bg-secondary: #f1f3f6;
  --bg-secondary-hover: #e4e7ed;
  --bg-tertiary: #f8f9fb;
  --brand: #2259f0;
  --brand-hover: #1c4ace;
  --brand-soft: #ecf0fe;
  --badge-bg: #d9e2fd;
  --badge-text: #13318c;
  --t1: #1d2236;
  --t2: #434c63;
  --t3: #7b859e;
  --t4: #a5adc0;
  --border: #e4e7ed;
  --border-strong: #cfd4de;
  --error: #f04438;
  --error-hover: #d92d20;
  --error-soft: #fef3f2;
  --ok: #558402;
  --ok-soft: #f4fcea;
  --warn: #b36d05;
  --warn-soft: #fff9ec;
  --r-xs: 4px;
  --r-sm: 8px;
  --r-m: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --shadow-pop: 0 8px 28px rgba(29, 34, 54, 0.16);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg-main);
  color: var(--t1);
  font-size: 14px;
  line-height: 20px;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
button:disabled { cursor: default; }
svg { display: block; flex-shrink: 0; }

/* ---------- persona bar (demo scaffolding) ---------- */
.persona-bar {
  flex: 0 0 auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px dashed var(--border-strong);
}
.persona-brand { display: flex; align-items: center; gap: 10px; }
.brand-title { font-weight: 600; font-size: 15px; }
.brand-tag {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--t3); background: var(--bg-secondary-hover); padding: 2px 8px; border-radius: 999px;
}
.persona-right { display: flex; align-items: center; gap: 12px; }
.persona-switch {
  display: inline-flex; background: var(--bg-secondary-hover); border-radius: var(--r-m); padding: 3px;
}
.persona-btn {
  padding: 5px 14px; border-radius: 9px; font-weight: 500; font-size: 13px; color: var(--t2);
}
.persona-btn.active { background: var(--bg-primary); color: var(--t1); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.persona-btn:disabled { color: var(--t4); }

/* ---------- product chrome ---------- */
.app {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 16px;
  padding: 16px;
}

.rail {
  flex: 0 0 64px;
  background: var(--bg-primary);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
}
.rail-logo { margin-bottom: 8px; }
.rail-btn {
  width: 40px; height: 40px; border-radius: var(--r-m);
  display: grid; place-items: center; color: var(--t2);
}
.rail-sep { width: 40px; height: 1px; background: var(--border); margin: 4px 0; }
.rail-group {
  width: 40px; height: 40px; border-radius: var(--r-m);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px;
}
.rail-group.active { box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--brand); }
.blurred { filter: blur(1.5px); opacity: .45; pointer-events: none; }

/* ---------- group sidebar ---------- */
.sidebar {
  flex: 0 0 320px;
  background: var(--bg-primary);
  border-radius: var(--r-lg);
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 16px;
}
.cover { height: 128px; position: relative; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.g-avatar {
  position: absolute; left: 20px; top: 60px;
  width: 96px; height: 96px; border-radius: var(--r-xl);
  display: grid; place-items: center; color: #fff; font-size: 40px; font-weight: 700;
  box-shadow: 0 0 0 4px var(--bg-primary);
}
.title-row {
  margin-top: 44px;
  padding: 0 12px 0 20px;
  display: flex; align-items: center; gap: 4px;
}
.g-title {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 16px; line-height: 24px; font-weight: 600; text-align: left;
  padding: 4px 0;
}
.g-title span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--t3);
}
.icon-btn:hover { background: var(--bg-secondary); color: var(--t1); }
.sections { padding: 0 12px; }

/* section = one folder (CollapsibleSection) */
.sec-head { display: flex; align-items: center; gap: 4px; padding-right: 4px; }
.sec-toggle {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 4px;
  padding: 16px 8px 4px;
  font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase;
  color: var(--t3); text-align: left;
}
.sec-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-chev { width: 16px; height: 16px; opacity: 0; transition: transform .2s ease-out, opacity .2s; }
.sec-head:hover .sec-chev, .is-collapsed .sec-chev { opacity: 1; }
.is-collapsed .sec-chev { transform: rotate(-90deg); }
.sec-toggle .badge { margin-left: auto; }
.sec-eye { color: var(--t4); }
.sec-actions { display: flex; align-items: center; gap: 2px; padding-top: 12px; }
.sec-btn {
  width: 24px; height: 24px; border-radius: 6px;
  display: grid; place-items: center; color: var(--t3);
  opacity: 0;
}
.sec-head:hover .sec-btn, .sec-btn:focus-visible { opacity: 1; }
.sec-btn:hover { color: var(--t1); background: var(--bg-secondary); }
.is-collapsed .sec-body { display: none; }
.section.is-hidden .sec-title { color: var(--t4); }

/* item row (Item size lg) */
.row {
  position: relative;
  display: flex; align-items: center;
  padding: 8px; margin-bottom: 4px;
  border-radius: var(--r-m);
  cursor: pointer;
}
.row:hover, .row.active { background: var(--bg-secondary); }
.row-icon { width: 24px; height: 24px; display: grid; place-items: center; flex-shrink: 0; }
.row-text {
  margin-left: 12px; min-width: 0; flex: 1;
  display: flex; align-items: baseline; gap: 6px;
}
.row-title { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-suffix { color: var(--t4); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; }
.row-eye { color: var(--t4); margin-left: 6px; }
.row .badge { margin-left: 8px; }
.row-menu {
  width: 24px; height: 24px; border-radius: 6px; margin-left: 4px;
  display: grid; place-items: center; color: var(--t3);
  opacity: 0;
}
.row:hover .row-menu, .row-menu:focus-visible { opacity: 1; }
.row-menu:hover { background: var(--bg-secondary-hover); color: var(--t1); }
.row.dimmed .row-icon, .row.dimmed .row-title { opacity: .45; }
.row.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); } 100% { background: transparent; } }
.empty-folder { color: var(--t4); font-size: 12px; line-height: 16px; padding: 4px 8px 8px; }

/* item icons */
.ic-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700;
}
.ic-dot { width: 10px; height: 10px; border-radius: 50%; }
.ic-plain { color: var(--t3); display: grid; place-items: center; }
.ic-app {
  width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center; color: #fff;
}

.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--brand); color: #fff;
  font-size: 12px; line-height: 20px; font-weight: 600; text-align: center;
  text-transform: none;
}

.hidden-toggle {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 8px 0; padding: 8px 10px; width: calc(100% - 16px);
  border: 1px dashed var(--border-strong); border-radius: var(--r-m);
  color: var(--t2); font-weight: 500; font-size: 13px;
}
.hidden-toggle:hover { background: var(--bg-tertiary); }

/* ---------- content pane ---------- */
.content {
  flex: 1 1 auto; min-width: 0;
  background: var(--bg-primary);
  border-radius: var(--r-lg);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.view-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-primary); z-index: 1;
}
.view-head .row-icon { transform: scale(1.25); }
.view-title { font-size: 19px; line-height: 24px; font-weight: 600; }
.view-sub { color: var(--t3); font-size: 13px; }
.view-head .spacer { flex: 1; }
.view-body { padding: 20px 24px 32px; max-width: 760px; }
.muted { color: var(--t3); }
.small { font-size: 12px; line-height: 16px; }

.post { display: flex; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.post:last-child { border-bottom: 0; }
.post-meta { color: var(--t3); font-size: 13px; }
.post-meta b { color: var(--t1); font-weight: 600; }
.post p { margin-top: 2px; }
.person {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px;
}
.person.sm { width: 28px; height: 28px; font-size: 12px; }

.topic {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-m); margin-bottom: 8px;
}
.topic-title { font-weight: 600; }
.topic .spacer { flex: 1; }
.topic-count { color: var(--t3); font-size: 13px; display: flex; align-items: center; gap: 4px; }

.msg { display: flex; gap: 10px; margin-bottom: 14px; }
.msg-bubble { background: var(--bg-secondary); border-radius: 4px 14px 14px 14px; padding: 8px 12px; }
.msg-bubble b { display: block; font-size: 12px; font-weight: 600; color: var(--t2); }
.composer {
  margin-top: 12px; height: 44px; border-radius: var(--r-m); border: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 14px; color: var(--t4);
}

.board {
  display: grid; grid-template-columns: repeat(8, 44px); grid-template-rows: repeat(8, 44px);
  border-radius: var(--r-sm); overflow: hidden; width: max-content; margin: 8px 0 16px;
  box-shadow: 0 0 0 1px var(--border-strong);
}
.board span {
  display: grid; place-items: center; font-size: 34px; line-height: 1;
  font-family: 'Segoe UI Symbol', 'DejaVu Sans', 'Apple Symbols', serif; color: #1d2236;
}
.board .l { background: #eef1f6; }
.board .d { background: #9fb0cf; }

.task {
  display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.task-box {
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border-strong);
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
}
.task.done .task-box { background: var(--ok); border-color: var(--ok); }
.task.done .task-text { color: var(--t4); text-decoration: line-through; }
.task-add { display: flex; gap: 8px; margin-top: 12px; }
.task-add input { flex: 1; }

.event {
  display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border);
}
.event-date {
  width: 52px; text-align: center; border-radius: var(--r-sm); background: var(--bg-secondary); padding: 6px 0;
  font-size: 12px; line-height: 16px; color: var(--t3); font-weight: 600; text-transform: uppercase;
}
.event-date b { display: block; font-size: 18px; line-height: 22px; color: var(--t1); }
.off-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.off-row .spacer { flex: 1; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; line-height: 16px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: var(--bg-secondary); color: var(--t2); white-space: nowrap;
}
.pill.brand { background: var(--badge-bg); color: var(--badge-text); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--error-soft); color: var(--error); }

.note-box {
  background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--r-m);
  padding: 12px 14px; color: var(--t2);
}
.placeholder-rows div {
  height: 44px; border-radius: var(--r-m); background: var(--bg-tertiary); margin-bottom: 8px;
  display: flex; align-items: center; padding: 0 14px; color: var(--t3);
}

/* ---------- app store ---------- */
.tabs { display: flex; gap: 20px; padding: 0 24px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 12px 0 10px; font-weight: 600; color: var(--t3);
  border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 6px;
}
.tab.active { color: var(--t1); border-bottom-color: var(--t1); }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.app-card {
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.app-card-top { display: flex; align-items: center; gap: 12px; }
.app-card-top .ic-app { width: 40px; height: 40px; border-radius: 11px; }
.app-card-top .ic-app svg { width: 22px; height: 22px; }
.app-name { font-weight: 600; font-size: 16px; line-height: 24px; }
.app-desc { color: var(--t2); flex: 1; }
.app-card-foot { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.app-state {
  color: var(--t3); font-size: 13px; min-width: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.app-state b { color: var(--t1); font-weight: 600; }
.appr-icon .ic-app { width: 36px; height: 36px; border-radius: 10px; }
.appr-icon .ic-app svg { width: 20px; height: 20px; }
.appr-name { display: flex; align-items: center; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 13px; font-weight: 500;
}
.chip:hover { background: var(--bg-secondary); }
.hint { color: var(--t3); margin-bottom: 16px; }

.req {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-m); margin-bottom: 8px;
}
.req-main { flex: 1; min-width: 0; }
.req-note { color: var(--t2); margin-top: 4px; font-style: italic; }
.req-actions { display: flex; gap: 8px; align-self: center; }
.list-label {
  font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase; color: var(--t3);
  margin: 20px 0 8px;
}

/* ---------- create group (template picker) ---------- */
.create { display: flex; flex-direction: column; min-height: 100%; }
.create-head { padding: 24px 24px 8px; }
.create-head h1 { font-size: 24px; line-height: 32px; font-weight: 600; }
.create-head p { color: var(--t3); margin-top: 4px; max-width: 680px; }
.tpl-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px;
  padding: 16px 24px 24px; flex: 1; align-content: start;
}
.tpl {
  text-align: left; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px;
  display: flex; flex-direction: column; gap: 8px; background: var(--bg-primary);
}
.tpl:hover { border-color: var(--border-strong); }
.tpl.selected { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: #fbfcff; }
.tpl-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tpl-name { font-weight: 600; font-size: 16px; line-height: 24px; }
.tpl-blurb { color: var(--t2); font-size: 13px; line-height: 18px; }
.tpl-preview {
  background: var(--bg-tertiary); border-radius: var(--r-m); padding: 6px 10px 8px;
  font-size: 12px; line-height: 16px;
}
.tp-folder { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--t3); margin-top: 6px; }
.tp-folder.fixed { color: var(--t4); }
.tp-item { display: flex; align-items: center; gap: 6px; padding: 2px 0; color: var(--t1); }
.tp-item .row-icon { width: 14px; height: 14px; }
.tp-item .ic-avatar { width: 14px; height: 14px; font-size: 7px; }
.tp-item .ic-app { width: 14px; height: 14px; border-radius: 4px; }
.tp-item .ic-app svg, .tp-item .ic-plain svg { width: 10px; height: 10px; }
.tp-item .ic-dot { width: 7px; height: 7px; }
.tp-empty { color: var(--t4); padding: 2px 0; font-style: italic; }
.create-foot {
  position: sticky; bottom: 0; background: var(--bg-primary);
  border-top: 1px solid var(--border);
  padding: 14px 24px; display: flex; align-items: flex-end; gap: 12px;
}
.create-foot label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; color: var(--t2); width: 340px; }

/* ---------- controls ---------- */
.btn {
  height: 40px; padding: 0 16px; border-radius: var(--r-m);
  font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn.small { height: 32px; padding: 0 12px; border-radius: var(--r-sm); font-size: 12px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.secondary { background: var(--bg-secondary); color: var(--t1); }
.btn.secondary:hover { background: var(--bg-secondary-hover); }
.btn.danger { background: var(--error); color: #fff; }
.btn.danger:hover { background: var(--error-hover); }
.btn:disabled { background: var(--bg-secondary); color: var(--t4); }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border-strong); border-radius: var(--r-m);
  background: var(--bg-primary); padding: 0 12px; height: 40px; font-size: 14px; outline: none;
}
.textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 500; color: var(--t2); }
.field small { color: var(--t3); }

/* ---------- modal ---------- */
.modal {
  margin: auto; border: 0; border-radius: var(--r-lg); width: min(460px, calc(100vw - 32px));
  box-shadow: var(--shadow-pop); padding: 0; color: var(--t1);
}
.modal::backdrop { background: rgba(241, 243, 246, 0.7); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal-head h2 { font-size: 17px; line-height: 24px; font-weight: 600; }
.modal-body { padding: 10px 20px 6px; }
.modal-body > p { color: var(--t2); margin-bottom: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 20px 20px; }
.type-opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: var(--r-m); margin-bottom: 4px;
}
.type-opt:hover { background: var(--bg-secondary); }
.type-ic {
  width: 36px; height: 36px; border-radius: 10px; background: var(--bg-secondary);
  display: grid; place-items: center; color: var(--t2); flex-shrink: 0;
}
.type-opt b { display: block; font-weight: 600; }
.type-opt span span { color: var(--t3); font-size: 13px; }
.consequences { margin: 0 0 14px 18px; color: var(--t2); }
.consequences li { margin-bottom: 4px; }

/* ---------- menu popover ---------- */
.menu {
  position: fixed; z-index: 50; min-width: 210px;
  background: var(--bg-primary); border-radius: var(--r-m); box-shadow: var(--shadow-pop);
  padding: 4px; border: 1px solid var(--border);
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px;
  padding: 0 10px; border-radius: var(--r-sm); text-align: left; font-size: 14px;
}
.menu button svg { color: var(--t3); }
.menu button:hover:not(:disabled) { background: var(--bg-secondary); }
.menu button.danger, .menu button.danger svg { color: var(--error); }
.menu button:disabled, .menu button:disabled svg { color: var(--t4); }
.menu hr { border: 0; height: 1px; background: var(--border); margin: 4px 6px; }

/* ---------- toasts ---------- */
.toast-stack {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center;
}
.toast {
  background: #292929; color: #fff; padding: 10px 16px; border-radius: var(--r-m);
  font-size: 14px; box-shadow: var(--shadow-pop);
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
