/* Treemilia editor — "Botanical" look */

:root {
  --bg: #FCFBF7;
  --canvas: #F6F5EF;
  --surface: #FFFFFF;
  --line: #E6E9E0;
  --line-soft: #EEF0EA;
  --ink: #1C2B22;
  --ink-2: #3A4A40;
  --muted: #5E6D63;
  --green: #2F6B4F;
  --green-ink: #24563F;
  --green-soft: #EEF4EA;
  --leaf: #8DB287;
  --danger: #A0402C;
  --f-bg: #F6E4D8; --f-ink: #7A4A2A;
  --m-bg: #DFE9F2; --m-ink: #2E4A63;
  --u-bg: #ECEEE8; --u-ink: #55605A;
  --shadow-sm: 0 1px 2px rgba(28, 43, 34, 0.05), 0 4px 14px rgba(28, 43, 34, 0.05);
  --shadow-lg: 0 24px 60px rgba(28, 43, 34, 0.16);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: Manrope, Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.app { display: grid; grid-template-rows: 64px 1fr; height: 100dvh; overflow: hidden; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid transparent;
  background: none; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }
.btn-ghost:hover:not(:disabled) { background: #F0F2EB; }
.btn-outline { background: var(--surface); border-color: var(--line); }
.btn-outline:hover { border-color: #CCD6C6; background: #FAFBF8; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8A3524; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 9px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.icon-btn { width: 38px; padding: 0; }
.icon-btn.btn-sm { width: 32px; }
.link-btn { background: none; border: 0; padding: 4px 2px; color: var(--green); font-weight: 700; font-size: 13.5px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; background: var(--green-soft); color: var(--green-ink); font-size: 12.5px; font-weight: 700; }
.pill.soon { background: #F3E9DC; color: #8A5233; }
.danger-text { color: var(--danger); }

/* ---------- top bar ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px; border-bottom: 1px solid var(--line); background: rgba(252, 251, 247, 0.92);
  backdrop-filter: blur(8px); position: relative; z-index: 20;
}
.tb-left, .tb-center, .tb-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-left { flex: 1 1 0; }
.tb-right { flex: 1 1 0; justify-content: flex-end; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; padding: 0 4px; }
.tb-sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.title-input {
  border: 1px solid transparent; background: none; border-radius: 9px; height: 36px; padding: 0 10px;
  font-weight: 700; font-size: 15px; min-width: 0; text-overflow: ellipsis;
}
.title-input:hover { background: #F0F2EB; }
.title-input:focus { outline: none; background: var(--surface); border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 107, 79, .12); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--leaf); transition: background .2s; }
.status[data-state="saving"] i { background: #D9B45A; }
.status[data-state="error"] i { background: var(--danger); }
.tool-group { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.tool-group .btn { height: 32px; border-radius: 9px; }
.tool-group .icon-btn { width: 32px; }
.zoom-label { min-width: 54px; padding: 0 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.flag-btn { width: 32px; height: 32px; border-radius: 50%; padding: 0; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line), var(--shadow-sm); cursor: pointer; margin-left: 6px; flex: none; transition: transform .15s, box-shadow .15s; }
.flag-btn:hover { transform: scale(1.06); box-shadow: 0 0 0 1px #CCD6C6, var(--shadow-sm); }
.flag { display: block; width: 100%; height: 100%; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }

/* ---------- workspace ---------- */

.workspace { display: flex; min-height: 0; position: relative; }

/* sidebar */
.sidebar { width: 268px; flex: none; display: flex; flex-direction: column; background: var(--bg); border-right: 1px solid var(--line); min-height: 0; transition: transform .25s ease; }
.app.sidebar-closed .sidebar { display: none; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 10px 20px; }
.sb-head h2 { margin: 0; font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.count { font-size: 12px; font-weight: 700; background: var(--green-soft); color: var(--green-ink); border-radius: 999px; padding: 2px 8px; }
.search { margin: 0 14px 8px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; color: var(--muted); }
.search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 107, 79, .1); }
.search input { border: 0; outline: none; background: none; height: 36px; flex: 1; min-width: 0; font-size: 13.5px; color: var(--ink); }
.people-list { flex: 1; overflow: auto; padding: 4px 8px; }
.person-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 12px; background: none; text-align: left; cursor: pointer; transition: background .12s; }
.person-item:hover { background: #F1F3EC; }
.person-item.active { background: var(--green-soft); }
.mini-av { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 11.5px; font-weight: 800; overflow: hidden; }
.mini-av img, .chip-av img { width: 100%; height: 100%; object-fit: cover; }
.pi-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pi-name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-name.unnamed { color: var(--muted); font-style: italic; font-weight: 600; }
.pi-years { font-size: 12px; color: var(--muted); }
.pi-flag { color: var(--green); display: grid; }
.list-empty { color: var(--muted); font-size: 13px; padding: 12px; line-height: 1.5; }
.sb-foot { padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line-soft); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.stats div { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 12px; padding: 8px 6px; text-align: center; display: flex; flex-direction: column; gap: 1px; }
.stats strong { font-size: 18px; font-weight: 800; }
.stats span { font-size: 11.5px; color: var(--muted); }
.tip { display: flex; gap: 10px; align-items: flex-start; background: var(--green-soft); border-radius: 14px; padding: 12px; }
.tip-leaf { flex: none; margin-top: -4px; }
.tip p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }

/* canvas */
.canvas {
  flex: 1; min-width: 0; position: relative; overflow: hidden; touch-action: none; cursor: default;
  background-color: var(--canvas);
  background-image: radial-gradient(circle, #D9DBD0 1px, transparent 1.3px);
  background-size: 24px 24px;
}
.canvas.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.l-child { fill: none; stroke: #B9CBB3; stroke-width: 1.7; stroke-linecap: round; }
.l-partner { fill: none; stroke: #D8C6B1; stroke-width: 1.7; }
.l-child.hl, .l-partner.hl { stroke: var(--green); stroke-width: 2.2; }
.l-dots circle { fill: #fff; stroke: #B9CBB3; stroke-width: 1.7; }

/* cards */
.card {
  position: absolute; width: 228px; height: 76px; display: flex; align-items: center; gap: 12px;
  padding: 0 14px 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-sm); cursor: grab; user-select: none; -webkit-user-select: none;
  transition: box-shadow .2s, border-color .2s;
}
.card:hover { border-color: #D4DDCE; box-shadow: 0 2px 4px rgba(28, 43, 34, .05), 0 10px 26px rgba(28, 43, 34, .08); }
.card.selected { border-color: var(--green); box-shadow: 0 0 0 4px rgba(47, 107, 79, .12), 0 10px 26px rgba(28, 43, 34, .08); z-index: 2; }
.card.dragging { cursor: grabbing; z-index: 10; box-shadow: 0 22px 48px rgba(28, 43, 34, .18); transform: rotate(-1deg) scale(1.02); }
.card.enter { animation: card-in .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes card-in { from { opacity: 0; transform: translateY(8px) scale(.92); } }
.avatar { width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 15px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.g-f .avatar, .g-f.mini-av, .chip-av.g-f, .avatar-lg.g-f, .pop-dot.g-f { background: var(--f-bg); color: var(--f-ink); }
.g-m .avatar, .g-m.mini-av, .chip-av.g-m, .avatar-lg.g-m, .pop-dot.g-m { background: var(--m-bg); color: var(--m-ink); }
.g-u .avatar, .g-u.mini-av, .chip-av.g-u, .avatar-lg.g-u, .pop-dot.g-u { background: var(--u-bg); color: var(--u-ink); }
.card.deceased .avatar { box-shadow: 0 0 0 2px #fff, 0 0 0 3px #CFC6B8; }
.meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name.unnamed { color: var(--muted); font-style: italic; font-weight: 600; }
.years { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-flag { position: absolute; right: 10px; top: 9px; color: var(--green); display: grid; }
.root-badge { position: absolute; top: -10px; left: 16px; background: var(--green); color: #fff; font-size: 11px; font-weight: 800; border-radius: 999px; padding: 2px 9px; box-shadow: 0 0 0 3px var(--canvas); }

.handle {
  position: absolute; width: 26px; height: 26px; border-radius: 50%; padding: 0;
  display: grid; place-items: center; background: var(--surface); border: 1px solid #CFDAC9; color: var(--green);
  cursor: pointer; opacity: 0; transform: scale(.5); pointer-events: none;
  transition: opacity .15s, transform .18s cubic-bezier(.2, .8, .2, 1), background .15s, color .15s;
  box-shadow: var(--shadow-sm);
}
.card:hover .handle, .card.selected .handle { opacity: 1; transform: scale(1); pointer-events: auto; }
.card.dragging .handle { opacity: 0 !important; pointer-events: none; }
.handle:hover { background: var(--green); border-color: var(--green); color: #fff; transform: scale(1.12); }
.h-top { left: calc(50% - 13px); top: -14px; }
.h-bottom { left: calc(50% - 13px); bottom: -14px; }
.h-right { right: -14px; top: calc(50% - 13px); }
.h-left { left: -14px; top: calc(50% - 13px); }

/* popover */
.popover {
  position: absolute; z-index: 30; min-width: 190px; max-width: 240px; padding: 6px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop-in .14s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: scale(.96); } }
.pop-title { font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 8px 10px 6px; }
.pop-note { margin: 0 10px 6px; font-size: 12.5px; line-height: 1.45; color: var(--ink-2); }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: none; font-weight: 700; font-size: 14px; cursor: pointer; text-align: left; }
.pop-item:hover:not(:disabled), .pop-item:focus-visible { background: var(--green-soft); outline: none; }
.pop-item:disabled { opacity: .4; cursor: default; }
.pop-dot { width: 22px; height: 22px; border-radius: 50%; flex: none; }

/* empty state */
.empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at center, rgba(252, 251, 247, .95) 30%, rgba(252, 251, 247, 0) 75%); }
.empty-card { max-width: 460px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; animation: card-in .6s ease both; }
.empty-branch { width: 220px; height: 120px; }
.empty-card h1 { margin: 0; font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.empty-card h1 em { font-family: var(--serif); font-weight: 600; font-size: 48px; color: var(--green); }
.empty-card p { margin: 0; font-size: 16px; line-height: 1.6; color: var(--ink-2); }
.start-form { display: flex; gap: 8px; width: 100%; max-width: 400px; margin-top: 6px; }
.start-form input { flex: 1; min-width: 0; height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--surface); font-size: 15px; }
.start-form input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 107, 79, .12); }

/* hint */
.canvas-hint {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 14px;
  box-shadow: var(--shadow-sm); font-size: 13.5px; color: var(--ink-2); max-width: calc(100% - 32px); animation: card-in .4s ease both;
}
.hint-ic { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: #fff; flex: none; }

/* ---------- person panel ---------- */

.panel { width: 384px; flex: none; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); min-height: 0; }
.panel.open { animation: panel-in .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes panel-in { from { opacity: 0; transform: translateX(16px); } }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--line-soft); }
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.panel-scroll { flex: 1; overflow: auto; padding: 20px 20px 28px; display: flex; flex-direction: column; gap: 26px; }
.p-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding-top: 4px; }
.avatar-lg { width: 108px; height: 108px; border-radius: 50%; position: relative; display: grid; place-items: center; font-size: 32px; font-weight: 800; box-shadow: 0 0 0 5px #fff, 0 0 0 6px var(--line), 0 14px 30px rgba(28, 43, 34, .12); margin-bottom: 10px; }
.avatar-lg > img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-btn { position: absolute; right: -2px; bottom: -2px; width: 36px; height: 36px; border-radius: 50%; border: 3px solid #fff; background: var(--green); color: #fff; display: grid; place-items: center; cursor: pointer; transition: transform .15s; }
.avatar-btn:hover { transform: scale(1.08); }
.p-name { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.p-years { font-size: 14px; color: var(--muted); }
.p-hero-actions { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.p-section { display: flex; flex-direction: column; gap: 12px; }
.section-title { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > span { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.field input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface);
  font-size: 14.5px; font-weight: 500; transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder, textarea::placeholder { color: #9AA59D; }
.field input:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 107, 79, .12); }
textarea { resize: vertical; min-height: 110px; line-height: 1.55; }
.seg { display: flex; background: #F2F3EE; border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { flex: 1; height: 34px; border: 0; background: none; border-radius: 9px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); cursor: pointer; transition: background .15s, box-shadow .15s; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(28, 43, 34, .12); font-weight: 700; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--green); }

/* audio */
.audio-card { border-radius: 16px; padding: 14px; background: var(--green-soft); border: 1px solid #DFEBDA; display: flex; align-items: center; gap: 12px; }
.empty-audio { flex-direction: column; align-items: stretch; background: #FAFBF7; border: 1px dashed #C9D8C3; }
.empty-audio p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.audio-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.play-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--green); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; transition: transform .15s; }
.play-btn:hover { transform: scale(1.06); }
.audio-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.audio-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.audio-row strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audio-time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12.5px; }
.audio-seek { width: 100%; accent-color: var(--green); margin: 0; }
.recording { background: #FBEDEA; border-color: #F1D3CC; }
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: #D2452C; flex: none; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(210, 69, 44, 0); } 0% { box-shadow: 0 0 0 0 rgba(210, 69, 44, .45); } }
.audio-meta { flex: 1; display: flex; flex-direction: column; font-size: 13.5px; }
.rec-time { color: var(--muted); font-variant-numeric: tabular-nums; }

/* relatives */
.rel-group { display: flex; flex-direction: column; gap: 8px; }
.rel-label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.rel-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 13px; cursor: pointer; max-width: 100%; transition: border-color .15s, background .15s; }
.chip:hover { border-color: var(--green); background: #FAFCF8; }
.chip-av { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 800; overflow: hidden; flex: none; }
.btn-add { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px 0 9px; border-radius: 999px; border: 1px dashed #BFD0B9; background: none; color: var(--green); font-weight: 700; font-size: 13px; cursor: pointer; transition: background .15s, border-color .15s; }
.btn-add:hover { background: var(--green-soft); border-color: var(--green); border-style: solid; }
.rel-empty { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.p-danger { padding-top: 8px; border-top: 1px solid var(--line-soft); align-items: flex-start; }

/* ---------- menus, modals, toasts ---------- */

.menu { position: fixed; z-index: 200; min-width: 250px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop-in .14s ease-out; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none; font-weight: 600; font-size: 14px; cursor: pointer; text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--green-soft); outline: none; }
.menu button .ic { color: var(--green); }
.menu small { margin-left: auto; color: var(--muted); font-size: 12px; }
.menu hr { border: 0; border-top: 1px solid var(--line-soft); margin: 6px 4px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 16px; background: rgba(28, 43, 34, .32); backdrop-filter: blur(3px); animation: fade .18s ease; }
.modal-backdrop.out { opacity: 0; transition: opacity .18s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(520px, 100%); max-height: 86vh; overflow: auto; background: var(--surface); border-radius: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .22); padding: 24px; animation: modal-in .24s cubic-bezier(.2, .8, .2, 1); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-sm { width: min(420px, 100%); }
.modal-lg { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.modal-title { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.modal-text { margin: 8px 0 0; font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

.lang-sub { margin: 18px 0 8px; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
.lang-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid transparent; background: none; font-weight: 600; font-size: 14px; cursor: pointer; text-align: left; }
.lang-item:hover { background: #F3F5EF; }
.lang-item.active { border-color: var(--green); background: var(--green-soft); font-weight: 700; }
.lang-item .flag { width: 26px; height: 26px; flex: none; }
.lang-item .ic { margin-left: auto; color: var(--green); }

.share-link { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; background: #F5F7F2; border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--muted); }
.share-link span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.share-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; transition: border-color .15s, background .15s; }
.share-opt:hover { border-color: var(--green); background: #FAFCF8; }
.share-opt > span { width: 36px; height: 36px; border-radius: 10px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; margin-bottom: 6px; }
.share-opt strong { font-size: 15px; }
.share-opt small { font-size: 13px; color: var(--muted); line-height: 1.45; }

.toasts { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: #fff; border-radius: 12px; padding: 11px 16px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toast-in .25s cubic-bezier(.2, .8, .2, 1); max-width: calc(100vw - 32px); }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- responsive ---------- */

@media (max-width: 1180px) { .hide-md { display: none; } }
@media (max-width: 900px) {
  .hide-sm { display: none !important; }
  .topbar { padding: 0 8px; gap: 6px; }
  .tb-left, .tb-right { flex: 0 1 auto; }
  .sidebar { position: absolute; top: 0; bottom: 0; left: 0; z-index: 25; transform: translateX(-100%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
  .app.sidebar-closed .sidebar { display: flex; }
  .app.sidebar-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition: transform .25s ease; }
  .title-input { max-width: 30vw; padding: 0 6px; }
  .tb-center { gap: 4px; }
  .tb-left, .tb-right { gap: 4px; }
  .topbar .icon-btn, .topbar #arrange, .topbar #export { width: 34px; padding: 0; }
  .tool-group .icon-btn { width: 30px; }
  .logo { padding: 0; }
  .flag-btn { margin-left: 2px; width: 30px; height: 30px; }
  .panel { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 74dvh; z-index: 40; border-left: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -20px 50px rgba(28, 43, 34, .18); }
  @keyframes panel-in { from { transform: translateY(40px); opacity: 0; } }
  .empty-card h1 { font-size: 32px; }
  .empty-card h1 em { font-size: 38px; }
  .start-form { flex-direction: column; }
}

/* ---------- embedded live demo (landing page) ---------- */

.app.embed { grid-template-rows: 1fr; }
.app.embed .topbar, .app.embed .sidebar, .app.embed .panel, .app.embed .empty, .app.embed .canvas-hint { display: none !important; }
.app.embed .canvas { background-color: #FAFAF6; }
.embed-bar { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 6px; background: rgba(255, 255, 255, .92); border: 1px solid var(--line); border-radius: 12px; padding: 4px; box-shadow: var(--shadow-sm); }
.embed-tip { position: absolute; right: 14px; top: 14px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: rgba(255, 255, 255, .92); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; box-shadow: var(--shadow-sm); }
@media (max-width: 600px) { .embed-tip { display: none; } }

/* ---------- print ---------- */

@page { size: A4 landscape; margin: 10mm; }
@media print {
  body { background: #fff; }
  .topbar, .sidebar, .panel, .canvas-hint, .popover, .toasts, .empty, .handle, .root-badge { display: none !important; }
  .app { display: block; height: auto; }
  .workspace { display: block; }
  .canvas { background: #fff; height: 190mm; overflow: hidden; }
  .card { box-shadow: none; break-inside: avoid; }
}
