/* Jajehelp OS */

:root {
  --bg: #F6F5F7;
  --surface: #FFFFFF;
  --surface-2: #EFEDF2;
  --text: #1B1920;
  --muted: #6D6776;
  --line: #CBC6D2;
  --line-soft: #E6E2EA;
  --pink: #FF4FA3;
  --pink-ink: #C21E6E;
  --pink-soft: #FFEAF4;
  --ok: #1E7A5F;
  --warn: #C7851A;
  --idle: #8D8795;
  --danger: #B3261E;
  --root-bg: #1B1920;
  --root-text: #F6F5F7;
  --root-muted: #B7B1BF;
  --zone-bg: rgba(109, 103, 118, 0.06);
  --glass: rgba(246, 245, 247, 0.72);
  --glass-line: rgba(27, 25, 32, 0.1);
  --shadow-win: 0 28px 70px -30px rgba(20, 12, 24, 0.55), 0 2px 8px rgba(20, 12, 24, 0.08);
  --overlay: rgba(14, 10, 18, 0.5);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--pink-ink);

  --ic-folder: #FFB3D6;
  --ic-folder-2: #F2849F;
  --ic-page: #FFFFFF;
  --ic-stroke: #B4AEBD;
  --ic-line: #D6D1DC;

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --taskbar-h: 48px;
  --radius: 6px;

  /* wallpaper, overwritten per phase */
  --wall-1: #16121A;
  --wall-2: #4A1838;
  --wall-3: #120F16;
  --wall-ink: #EEEBF1;
  --wall-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  --rings-opacity: 0.16;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131116;
    --surface: #1C1A21;
    --surface-2: #26232C;
    --text: #EEEBF1;
    --muted: #A39DAB;
    --line: #3B3643;
    --line-soft: #2B2831;
    --pink-ink: #FF7DBC;
    --pink-soft: #3A1A2B;
    --ok: #43B892;
    --warn: #E0A43F;
    --danger: #F2847D;
    --root-bg: #EEEBF1;
    --root-text: #131116;
    --root-muted: #5E5866;
    --zone-bg: rgba(255, 255, 255, 0.03);
    --glass: rgba(22, 19, 27, 0.72);
    --glass-line: rgba(255, 255, 255, 0.08);
    --ic-folder: #F48DBE;
    --ic-folder-2: #C85B8C;
    --ic-page: #2E2A34;
    --ic-stroke: #6A6372;
    --ic-line: #4B4553;
    color-scheme: dark;
  }
}

:root[data-phase="night"] { --wall-1: #0E0B12; --wall-2: #3A1230; --wall-3: #150F1B; --wall-ink: #EEEBF1; --rings-opacity: 0.12; }
:root[data-phase="dawn"] { --wall-1: #2B1C33; --wall-2: #FF97C4; --wall-3: #57304F; --wall-ink: #FFFFFF; --rings-opacity: 0.22; }
:root[data-phase="day"] { --wall-1: #F1EDF4; --wall-2: #FFC7E1; --wall-3: #E4DEEA; --wall-ink: #1B1920; --wall-shadow: 0 1px 2px rgba(255, 255, 255, 0.9); --rings-opacity: 0.32; }
:root[data-phase="dusk"] { --wall-1: #28152F; --wall-2: #FF5AA8; --wall-3: #1B1222; --wall-ink: #FFFFFF; --rings-opacity: 0.2; }
:root[data-phase="evening"] { --wall-1: #16121A; --wall-2: #4A1838; --wall-3: #120F16; --wall-ink: #EEEBF1; --rings-opacity: 0.16; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body.os {
  background: var(--wall-1);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
svg { display: block; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
.mono { font-family: var(--mono); font-size: 0.7rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* ---------- wallpaper ---------- */
.wallpaper {
  position: fixed; inset: 0;
  background:
    radial-gradient(85% 70% at 90% 108%, var(--wall-2) 0%, transparent 62%),
    radial-gradient(55% 45% at 8% -5%, color-mix(in oklab, var(--wall-2) 22%, transparent), transparent 70%),
    linear-gradient(165deg, var(--wall-1), var(--wall-3));
  transition: background 1.5s var(--ease);
}
.wallpaper__rings {
  position: absolute; right: -14vmin; bottom: -22vmin; width: 78vmin; height: 78vmin;
  color: var(--pink); opacity: var(--rings-opacity);
  animation: breathe 14s ease-in-out infinite alternate;
}
@keyframes breathe { from { transform: scale(1) rotate(0deg); } to { transform: scale(1.04) rotate(8deg); } }
.wallpaper__claim {
  position: absolute; left: 50%; bottom: calc(var(--taskbar-h) + 18px); transform: translateX(-50%);
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.4em; text-transform: lowercase;
  color: var(--wall-ink); opacity: 0.32; white-space: nowrap;
}

/* ---------- desktop icons ---------- */
.desktop { position: fixed; inset: 0 0 var(--taskbar-h) 0; }
.icon {
  position: absolute;
  left: min(calc(var(--x) * 1%), calc(100% - 96px));
  top: min(calc(var(--y) * 1%), calc(100% - 104px));
  width: 92px; padding: 8px 4px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; background: none;
  color: var(--wall-ink); cursor: pointer; touch-action: none;
  transition: background-color 0.16s var(--ease), border-color 0.16s var(--ease);
}
.icon__img { width: 48px; height: 48px; transition: transform 0.2s var(--ease); }
.icon__img svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.18)); }
.icon__label {
  font-size: 0.78rem; line-height: 1.25; text-align: center; font-weight: 500;
  text-shadow: var(--wall-shadow);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.icon:hover { background: color-mix(in oklab, var(--wall-ink) 10%, transparent); }
.icon:hover .icon__img { transform: translateY(-2px); }
.icon:focus-visible { background: color-mix(in oklab, var(--wall-ink) 14%, transparent); border-color: color-mix(in oklab, var(--wall-ink) 35%, transparent); box-shadow: none; }
.icon.is-offline .icon__img { opacity: 0.45; filter: grayscale(0.6); }
.icon.is-dragging { z-index: 5; cursor: grabbing; background: color-mix(in oklab, var(--wall-ink) 16%, transparent); }
.is-editmode .desktop .icon { cursor: grab; }

/* ---------- windows ---------- */
.win-layer { position: fixed; inset: 0 0 var(--taskbar-h) 0; pointer-events: none; z-index: 20; }
.win {
  position: absolute; pointer-events: auto;
  display: flex; flex-direction: column;
  min-width: 300px; min-height: 200px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-win);
  overflow: hidden; resize: both;
  user-select: text;
  animation: win-in 0.22s var(--ease);
}
@keyframes win-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } }
.win:not(.is-active) { box-shadow: 0 16px 40px -28px rgba(20, 12, 24, 0.5); }
.win.is-max { left: 8px !important; top: 8px !important; width: calc(100% - 16px) !important; height: calc(100% - 16px) !important; resize: none; }
.win.is-dragging { user-select: none; }
.win__bar {
  display: flex; align-items: center; gap: 8px; height: 40px; flex: none;
  padding-block: 0; padding-inline: 12px 4px; border-bottom: 1px solid var(--line-soft);
  cursor: grab; user-select: none; touch-action: none;
}
.win.is-dragging .win__bar { cursor: grabbing; }
.win__icon { width: 18px; height: 18px; flex: none; }
.win__icon svg { width: 18px; height: 18px; }
.win__title {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 0.72rem; font-weight: 500; letter-spacing: 0.04em;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.win.is-active .win__title { color: var(--text); }
.win__actions { display: flex; align-items: center; gap: 2px; }
.win__btn {
  display: grid; place-items: center; width: 34px; height: 30px;
  border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; text-decoration: none;
}
.win__btn svg { width: 16px; height: 16px; }
.win__btn:hover { background: var(--surface-2); color: var(--text); }
.win__btn--close:hover { background: #E0413A; color: #fff; }
.win__body { position: relative; flex: 1; min-height: 0; overflow: auto; }
.win__frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }

/* ---------- taskbar ---------- */
.taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; height: var(--taskbar-h);
  display: flex; align-items: center; gap: 4px; padding: 0 6px;
  background: var(--glass); border-top: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
  color: var(--text);
}
.task-start, .tray-btn, .task {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; border: 0; border-radius: 6px; background: none; cursor: pointer; text-decoration: none;
  transition: background-color 0.15s var(--ease);
}
.task-start { width: 42px; }
.task-start svg { width: 26px; height: 26px; transition: transform 0.4s var(--ease); }
.task-start:hover svg, .task-start[aria-expanded="true"] svg { transform: rotate(90deg) scale(1.06); }
.task-start:hover, .tray-btn:hover, .task:hover { background: color-mix(in oklab, var(--text) 8%, transparent); }
.task-list { flex: 1; min-width: 0; display: flex; gap: 2px; overflow: hidden; }
.task { position: relative; max-width: 190px; padding: 0 10px; font-size: 0.8rem; min-width: 0; }
.task__icon svg { width: 18px; height: 18px; }
.task__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 6px; height: 2px; margin-left: -3px; border-radius: 2px; background: var(--muted); transition: width 0.2s var(--ease), margin 0.2s var(--ease); }
.task[aria-pressed="true"] { background: color-mix(in oklab, var(--text) 7%, transparent); }
.task[aria-pressed="true"]::after { width: 18px; margin-left: -9px; background: var(--pink); }
.tray { display: flex; align-items: center; gap: 1px; }
.tray-btn { min-width: 36px; padding: 0 8px; color: var(--text); }
.tray-btn svg { width: 20px; height: 20px; }
.tray-lang { font-family: var(--mono); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; }
.tray-clock { flex-direction: column; gap: 0; align-items: flex-end; line-height: 1.2; font-size: 0.74rem; font-variant-numeric: tabular-nums; padding: 0 10px; }
.edit-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; margin-inline-end: 6px;
  font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--text); border: 1px solid var(--line);
}
.edit-toggle svg { width: 13px; height: 13px; }
.edit-toggle[aria-pressed="true"] { background: var(--pink-soft); color: var(--pink-ink); border-color: var(--pink); }
.edit-toggle[data-state="error"][aria-pressed="true"] { background: var(--danger); color: #fff; border-color: var(--danger); }
.statusbar { display: none; }

/* ---------- flyouts (start + tray) ---------- */
.flyout {
  position: fixed; inset: auto; margin: 0; padding: 0;
  width: min(340px, calc(100vw - 16px)); max-height: calc(100dvh - var(--taskbar-h) - 24px); overflow: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-win);
  user-select: text;
}
.flyout--wide { width: min(520px, calc(100vw - 16px)); }
.flyout:popover-open { animation: fly-in 0.2s var(--ease); }
@keyframes fly-in { from { opacity: 0; transform: translateY(6px); } }
.fly { padding: 18px; display: grid; gap: 12px; }
.fly__head { display: grid; gap: 2px; }
.fly__title { font-weight: 600; font-size: 1rem; }
.fly__lead { color: var(--text); }
.fly__muted { color: var(--muted); font-size: 0.86rem; }
.fly__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fly__admin { display: grid; gap: 8px; padding-top: 12px; border-top: 1px dashed var(--pink); }
.fly__admin ul { display: grid; gap: 6px; }

.batt__level { font-size: 2.6rem; font-weight: 600; letter-spacing: -0.04em; line-height: 1; display: flex; align-items: baseline; gap: 10px; }
.batt__word { font-size: 0.86rem; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.batt__bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.batt__fill { display: block; height: 100%; border-radius: 4px; transition: width 0.4s var(--ease); }
.range { width: 100%; accent-color: var(--pink); }

.langs li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 9px 0; border-top: 1px solid var(--line-soft); align-items: center; }
.langs li:first-child { border-top: 0; }
.langs__name { font-weight: 500; }
.langs__label { grid-column: 1 / -1; font-size: 0.76rem; color: var(--muted); }
.pips { display: flex; gap: 3px; }
.pip { width: 14px; height: 6px; border-radius: 2px; background: var(--line-soft); }
.pip.is-on { background: var(--pink); }
.langs__edit { display: grid; grid-template-columns: 1fr 72px 1fr auto; gap: 6px; }

.fly--cal { gap: 6px; padding: 12px 12px 14px; }
.cal__head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 6px; }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal__dow { font-family: var(--mono); font-size: 0.62rem; color: var(--muted); padding: 4px 0; }
.cal__day {
  position: relative; aspect-ratio: 1; border: 0; border-radius: 50%; background: none; cursor: pointer;
  font-size: 0.8rem; font-variant-numeric: tabular-nums;
}
.cal__day:hover { background: var(--surface-2); }
.cal__day.is-out { color: var(--line); }
.cal__day.is-today { background: var(--text); color: var(--surface); font-weight: 600; }
.cal__day.is-selected { box-shadow: inset 0 0 0 1.5px var(--pink); }
.cal__day.has-event::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--pink); }
.cal__list { display: grid; gap: 6px; margin-top: 8px; padding: 10px 4px 0; border-top: 1px solid var(--line-soft); }
.cal__event { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: baseline; padding: 3px 0; font-size: 0.88rem; }
.cal__event--edit { grid-template-columns: 132px 1fr auto; align-items: center; }
.cal__new { display: grid; grid-template-columns: 132px 1fr auto; gap: 6px; margin-top: 6px; }

/* start menu */
.start { display: grid; gap: 14px; padding: 18px; }
.start__me { display: flex; align-items: center; gap: 12px; }
.start__avatar svg { width: 40px; height: 40px; }
.start__name { font-weight: 600; font-size: 1.05rem; }
.start__search { width: 100%; }
.start__pinned { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 4px; }
.start__tile {
  display: grid; justify-items: center; gap: 6px; padding: 10px 4px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  font-size: 0.76rem; text-align: center;
}
.start__tile:hover { background: var(--surface-2); }
.start__tileicon svg { width: 36px; height: 36px; }
.start__tileicon--cal {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--line); border-top: 7px solid var(--pink);
  font-weight: 600; font-size: 0.9rem; font-variant-numeric: tabular-nums;
}
.start__results { display: grid; gap: 2px; }
.start__hit { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: none; text-align: start; cursor: pointer; }
.start__hit:hover, .start__hit:focus-visible { background: var(--surface-2); }
.start__hit small { display: block; color: var(--muted); font-size: 0.72rem; }
.start__hiticon svg { width: 28px; height: 28px; }
.start__none { color: var(--muted); padding: 8px; }
.start__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.start__power { display: flex; flex-wrap: wrap; gap: 2px; }

/* ---------- context menu ---------- */
.ctx {
  position: fixed; inset: auto; margin: 0; min-width: 210px; padding: 6px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-win);
}
.ctx button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: none; text-align: start; font-size: 0.88rem; cursor: pointer; }
.ctx button:hover, .ctx button:focus-visible { background: var(--surface-2); box-shadow: none; }
.ctx button.is-danger { color: var(--danger); }
.ctx button[disabled] { color: var(--muted); cursor: default; background: none; }
.ctx__sep { height: 1px; margin: 5px 4px; background: var(--line-soft); }

/* ---------- folder, text, props windows ---------- */
.folder { display: flex; flex-direction: column; min-height: 100%; }
.folder__bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line-soft); font-size: 0.8rem; color: var(--muted); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.folder__path { display: flex; flex-wrap: wrap; align-items: center; }
.folder__path strong { color: var(--text); font-weight: 600; }
.folder__path [aria-hidden="true"] { margin: 0 6px; opacity: 0.6; }
.folder__path .link { border: 0; background: none; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.folder__tools { display: flex; gap: 6px; }
.folder__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; padding: 16px; align-content: start; }
.folder__grid .icon { position: static; width: auto; color: var(--text); }
.folder__grid .icon__label { text-shadow: none; }
.folder__grid .icon:hover { background: var(--surface-2); }
.folder__grid .icon:focus-visible { background: var(--surface-2); border-color: var(--pink); }
.folder__empty { grid-column: 1 / -1; color: var(--muted); padding: 12px 4px; }
.folder__readme { margin: 0 16px 16px; padding: 18px 20px; border: 1px solid var(--line-soft); border-radius: 8px; background: var(--bg); }

.doc { position: relative; padding: 24px 28px 32px; display: grid; gap: 12px; align-content: start; min-height: 100%; }
.doc__edit { position: absolute; top: 14px; inset-inline-end: 14px; }
.doc__editbar { display: flex; gap: 8px; }
.doc__area.textarea { min-height: min(360px, 50vh); height: auto; font-family: var(--mono); font-size: 0.86rem; line-height: 1.6; resize: vertical; }
.doc__hint { text-transform: none; letter-spacing: 0.02em; }
.doc__confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--danger); border-radius: var(--radius); font-size: 0.88rem; }

.prose { max-width: 62ch; color: var(--text); user-select: text; }
.prose h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; margin-bottom: 12px; }
.prose h2 { font-size: 1.15rem; font-weight: 600; margin: 18px 0 6px; }
.prose h3 { font-size: 1rem; font-weight: 600; margin: 14px 0 4px; }
.prose p { margin: 0 0 12px; color: var(--muted); }
.prose ul { margin: 0 0 12px; padding-inline-start: 18px; list-style: square; color: var(--muted); }
.prose li::marker { color: var(--pink); }
.prose a { color: var(--pink-ink); font-weight: 500; text-underline-offset: 3px; }
.prose strong { color: var(--text); }
.prose code { font-family: var(--mono); font-size: 0.85em; background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }

.props { display: grid; gap: 14px; padding: 18px; }
.props__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; }
.check input { accent-color: var(--pink); width: 16px; height: 16px; }
.versions { display: grid; }
.versions li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }

/* ---------- terminal ---------- */
.win--term .win__body { background: #141217; }
.term { height: 100%; overflow: auto; padding: 12px 14px 16px; background: #141217; color: #E7E3EC; font-family: var(--mono); font-size: 13px; line-height: 1.55; cursor: text; }
.term__row { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.55em; }
.term__row.is-muted { color: #8F889A; }
.term__row.is-err { color: #FF8A8A; }
.term__row.is-dir { color: #FF9CCB; }
.term__row.is-accent { color: #FF4FA3; }
.term__row.is-echo { color: #BDB6C7; }
.term__line { display: flex; gap: 6px; align-items: baseline; }
.term__prompt { white-space: nowrap; color: #BDB6C7; }
.term__in { flex: 1; min-width: 40px; border: 0; background: none; color: #fff; font: inherit; outline: none; caret-color: #FF4FA3; padding: 0; }
.term__in:focus-visible { box-shadow: none; }

/* ---------- ecosystem window ---------- */
.ecowin { display: flex; height: 100%; }
.ecowin__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ecowin__top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.ecowin__toolbar { padding: 8px 12px 0; }
.ecowin__canvas { flex: 1; min-height: 0; overflow: auto; padding: 12px 16px 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.8rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.legend__line { width: 24px; border-top: 1.5px solid var(--line); }
.legend__dots { width: 24px; height: 3px; background: radial-gradient(circle, var(--pink) 1.3px, transparent 1.6px) 0 50% / 6px 3px repeat-x; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--idle { background: var(--idle); }
.eco__stage { border: 1px solid var(--line-soft); border-radius: 8px; background: var(--surface); overflow-x: auto; }
.eco__stage:has(.is-selected) { border-color: var(--pink); }
.eco__svg { margin: 0 auto; }
.eco__scrollhint { display: none; margin-top: 8px; text-align: center; }
.eco__stage.is-scrollable + .eco__scrollhint { display: block; }
.eco__list { display: none; }
@media (max-width: 699px) {
  .eco__stage, .eco__stage.is-scrollable + .eco__scrollhint { display: none; }
  .eco__list { display: block; }
}

.c-zone rect { fill: var(--zone-bg); stroke: none; }
.c-zone text { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; fill: var(--muted); }
.c-edge { fill: none; transition: opacity 0.18s var(--ease); }
.c-edge--tree { stroke: var(--line); stroke-width: 1.25; }
.c-edge--client { stroke: var(--pink); stroke-width: 2.6; stroke-dasharray: 0.1 6; stroke-linecap: round; }
.c-node { transition: opacity 0.18s var(--ease); outline: none; }
.c-node rect { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.c-node .c-type { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; fill: var(--muted); }
.c-node .c-name { font-family: var(--font); font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; fill: var(--text); }
.c-node .c-meta { font-family: var(--font); font-size: 13px; fill: var(--muted); }
.c-node--brand rect { fill: var(--pink-soft); stroke: var(--pink); }
.c-node--root rect { fill: var(--root-bg); stroke: var(--root-bg); }
.c-node--root .c-type, .c-node--root .c-meta { fill: var(--root-muted); }
.c-node--root .c-name { fill: var(--root-text); }
.c-status--ok { fill: var(--ok); }
.c-status--warn { fill: var(--warn); }
.c-status--idle { fill: var(--idle); }
.c-node:focus-visible rect, .c-node.is-selected rect { stroke: var(--pink-ink); stroke-width: 2; }
.c-node.is-clickable { cursor: pointer; }
.c-node.is-clickable:hover rect { stroke: var(--text); }
.c-node--root.is-clickable:hover rect { stroke: var(--pink); }
.c-action { font-family: var(--mono); font-size: 12px; font-weight: 600; fill: var(--pink-ink); pointer-events: none; }
.c-node--root .c-action { fill: var(--pink); }
.has-focus .c-node:not(.is-related), .has-focus .c-edge:not(.is-related) { opacity: 0.22; }

.tree-root { padding: 14px; display: grid; gap: 4px; border-radius: 8px; background: var(--root-bg); color: var(--root-text); }
.tree-root .mono { color: var(--root-muted); }
.tree-root__meta { color: var(--root-muted); font-size: 0.9rem; }
.tree-root .btn { margin-top: 8px; justify-self: start; background: transparent; color: var(--root-text); border-color: var(--root-muted); }
.tree-zones { display: grid; gap: 12px; margin-top: 12px; }
.tree-zone { padding: 12px 12px 4px; border: 1px solid var(--line-soft); border-radius: 8px; }
.tree-zone > .mono { display: block; margin-bottom: 6px; }
.tree-item { padding: 10px 0; border-top: 1px solid var(--line-soft); }
.tree-zone > ul > .tree-item:first-child { border-top: 0; }
.tree-item ul { margin-inline-start: 12px; padding-inline-start: 12px; border-inline-start: 1px solid var(--line); }
.tree-item ul .tree-item { border-top: 0; padding-bottom: 4px; }
.tree-card { display: grid; gap: 2px; }
.tree-card__name { font-weight: 600; }
.tree-card__meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.86rem; }
.tree-card--brand .tree-card__name { color: var(--pink-ink); }
.tree-card__client { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--pink-ink); margin-top: 4px; }
.tree-card__client::before { content: ""; width: 18px; height: 3px; flex: none; background: radial-gradient(circle, var(--pink) 1.3px, transparent 1.6px) 0 50% / 6px 3px repeat-x; }
.tree-card.is-clickable { cursor: pointer; }
.tree-card.is-selected .tree-card__name { text-decoration: underline; text-decoration-color: var(--pink); text-underline-offset: 3px; }

/* ecosystem editor inside the window */
.eco-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; border: 1px solid var(--pink); border-radius: 8px; background: var(--pink-soft); }
.eco-toolbar__spacer { flex: 1 1 auto; }
.eco-toolbar__dirty { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; color: var(--pink-ink); }
.eco-toolbar__confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; padding-top: 8px; border-top: 1px solid var(--pink); font-size: 0.86rem; }
.editor { width: 330px; flex: none; border-inline-start: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.editor__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.editor__body { flex: 1; overflow: auto; padding: 14px; display: grid; gap: 12px; align-content: start; }
.editor__body h3 { font-size: 0.95rem; font-weight: 600; }
.editor__row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.editor__row .field { flex: 1 1 130px; }
.editor__note { font-size: 0.8rem; color: var(--muted); }
.editor__errors { border: 1px solid var(--danger); border-radius: var(--radius); padding: 10px 12px; color: var(--danger); font-size: 0.84rem; }
.editor__errors ul { list-style: disc; padding-inline-start: 18px; margin-top: 6px; }
.editor__list li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line-soft); }
.editor__list li:first-child { border-top: 0; }
.editor__list .grow { flex: 1; min-width: 0; }
.confirm-box { border: 1px solid var(--danger); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; font-size: 0.88rem; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-size: 0.86rem; font-weight: 500; line-height: 1; white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.btn:hover { border-color: var(--text); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }
.btn--small { min-height: 30px; padding: 0 10px; font-size: 0.8rem; }
.btn--primary { background: var(--text); border-color: var(--text); color: var(--surface); }
.btn--primary:hover { background: var(--pink-ink); border-color: var(--pink-ink); color: #fff; }
.btn--quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn--quiet:hover { color: var(--text); border-color: var(--line); }
.btn--danger { color: var(--danger); }
.btn--danger:hover { border-color: var(--danger); }
.btn--danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.link-btn { background: none; border: 0; padding: 0; cursor: pointer; color: var(--pink-ink); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.field { display: grid; gap: 5px; }
.field label, .field__label { font-size: 0.8rem; font-weight: 500; }
.field__note { font-size: 0.78rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text);
  user-select: text;
}
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 2px solid var(--pink-ink); outline-offset: 0; box-shadow: none; }
.input--color { padding: 3px; height: 36px; }
.input--code { font-family: var(--mono); font-size: 1.2rem; letter-spacing: 0.4em; }
.form-error { color: var(--danger); font-size: 0.84rem; min-height: 1.2em; }
.form-error small { display: block; margin-top: 4px; font-family: var(--mono); font-size: 0.7rem; color: var(--muted); overflow-wrap: anywhere; user-select: all; }

/* ---------- lock + boot ---------- */
.lock {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 13vh 24px 56px;
  color: #fff; cursor: pointer; outline: none;
  background:
    linear-gradient(rgba(10, 6, 14, 0.36), rgba(10, 6, 14, 0.5)),
    radial-gradient(85% 70% at 90% 108%, var(--wall-2) 0%, transparent 62%),
    linear-gradient(165deg, var(--wall-1), var(--wall-3));
  transition: transform 0.48s var(--ease), opacity 0.48s var(--ease);
}
.is-unlocked .lock { display: none; }
.lock.is-leaving { transform: translateY(-100%); }
@media (prefers-reduced-motion: reduce) { .lock.is-leaving { transform: none; opacity: 0; } }
.lock__clock { text-align: center; }
.lock__time { font-size: clamp(4.5rem, 15vw, 9.5rem); font-weight: 300; letter-spacing: -0.05em; line-height: 1; font-variant-numeric: tabular-nums; }
.lock__date { margin-top: 10px; font-size: 1.1rem; opacity: 0.86; }
.lock__user { display: grid; justify-items: center; gap: 10px; }
.lock__avatar svg { width: 76px; height: 76px; animation: breathe 6s ease-in-out infinite alternate; }
.lock__name { font-size: 1.25rem; font-weight: 500; }
.lock__hint { color: rgba(255, 255, 255, 0.62); }
.lock__swipe { display: none; }
.lock__other {
  position: absolute; inset-inline-start: 24px; bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.28); border-radius: 999px; background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.86); padding: 8px 14px; font-size: 0.82rem; cursor: pointer;
}
.lock__other:hover { background: rgba(255, 255, 255, 0.16); }
.lock:focus-visible .lock__hint { color: #fff; }
.boot { position: fixed; inset: 0; z-index: 3100; display: grid; place-items: center; background: #0B090D; }
.boot__rings svg { width: 64px; height: 64px; animation: spin 1.2s var(--ease) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login (above the lock screen) ---------- */
.login {
  position: fixed; inset: 0; z-index: 3300; margin: auto; height: fit-content;
  width: min(400px, calc(100vw - 24px)); padding: 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-win); user-select: text;
}
.login-backdrop { position: fixed; inset: 0; z-index: 3200; background: var(--overlay); }
.login__head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.login__head h2 { font-size: 1rem; font-weight: 600; }
.login__body { padding: 18px; display: grid; gap: 12px; }
.login__body p { color: var(--muted); font-size: 0.86rem; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 3500; left: 50%; bottom: calc(var(--taskbar-h) + 14px); transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; padding: 11px 14px; border-radius: 8px; background: var(--text); color: var(--surface); font-size: 0.86rem; box-shadow: var(--shadow-win); animation: fly-in 0.22s var(--ease); }
.toast--error { background: var(--danger); color: #fff; }

.noscript { position: fixed; inset: 0; z-index: 10; padding: 40px 24px; background: var(--bg); color: var(--text); display: grid; gap: 12px; align-content: start; user-select: text; }

/* ---------- selection, edit mode ---------- */
.icon.is-selected { background: color-mix(in oklab, var(--wall-ink) 16%, transparent); border-color: color-mix(in oklab, var(--wall-ink) 40%, transparent); }
.folder__grid .icon.is-selected { background: var(--pink-soft); border-color: var(--pink); }
.no-rings .wallpaper__rings { display: none; }
.edit-banner {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 900;
  max-width: calc(100vw - 24px); padding: 7px 14px; border-radius: 999px;
  background: var(--pink-soft); color: var(--pink-ink); border: 1px solid var(--pink);
  font-size: 0.76rem; font-weight: 500; text-align: center; box-shadow: 0 6px 20px -12px rgba(20, 12, 24, 0.5);
  pointer-events: none;
}
.is-editmode .desktop .icon { border: 1px dashed color-mix(in oklab, var(--wall-ink) 34%, transparent); }
.is-editmode .desktop .icon:hover { border-color: var(--pink); }
.is-editmode .folder__grid .icon { border: 1px dashed var(--line); }
.is-editmode .folder__grid .icon:hover { border-color: var(--pink); }
.grow { flex: 1 1 auto; }

/* ---------- language tabs + fields ---------- */
.langtabs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.langtabs .mono { margin-inline-end: 6px; }
.langtabs__btn {
  min-width: 42px; height: 28px; padding: 0 8px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font-family: var(--mono); font-size: 0.66rem; font-weight: 600; letter-spacing: 0.08em;
}
.langtabs__btn:hover { color: var(--text); border-color: var(--text); }
.langtabs__btn[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }
.field__lang {
  display: inline-block; margin-inline-start: 6px; padding: 0 5px; border-radius: 3px;
  font-family: var(--mono); font-size: 0.6rem; font-weight: 600; letter-spacing: 0.06em; line-height: 1.5;
  background: var(--surface-2); color: var(--muted); vertical-align: 1px;
}
.langswitch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.langswitch__btn {
  min-height: 40px; padding: 0 8px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 0.9rem;
}
.langswitch__btn[lang="ar"] { font-family: "IBM Plex Sans Arabic", var(--font); }
.langswitch__btn:hover { border-color: var(--text); }
.langswitch__btn[aria-pressed="true"] { border-color: var(--pink); background: var(--pink-soft); color: var(--pink-ink); font-weight: 600; }

/* ---------- leave dialog ---------- */
.leave {
  width: min(420px, calc(100vw - 24px)); padding: 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-win); user-select: text;
}
.leave::backdrop { background: var(--overlay); }
.leave[open] { animation: fly-in 0.2s var(--ease); }
.leave__inner { display: grid; gap: 12px; padding: 20px; }
.leave__inner h2 { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.leave__body { color: var(--muted); font-size: 0.9rem; }
.leave__url {
  font-family: var(--mono); font-size: 0.76rem; padding: 8px 10px; border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); overflow-wrap: anywhere; text-align: left;
}
.leave__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- settings, note windows ---------- */
.settings { display: grid; gap: 16px; padding: 18px; align-content: start; }
.settings__group { display: grid; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.settings__group h3 { font-size: 0.95rem; font-weight: 600; }
.settings__row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.note { display: grid; gap: 6px; padding: 22px 24px; align-content: start; }
.note__title { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; }
.note__text { color: var(--muted); white-space: pre-line; }
.win--note .win__body { background: linear-gradient(180deg, var(--pink-soft), var(--surface) 70%); }

/* ---------- start menu extras ---------- */
.start__sub { color: var(--muted); font-size: 0.84rem; line-height: 1.35; }
.start__owner { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; border: 1px dashed var(--pink); border-radius: 8px; }
.start__owner .btn[aria-pressed="true"] { background: var(--pink-soft); border-color: var(--pink); color: var(--pink-ink); }
.start__claim { letter-spacing: 0.2em; }

/* ---------- ecosystem extras ---------- */
.legend__hint { color: var(--pink-ink); font-family: var(--mono); font-size: 0.72rem; }
.tree-card__action { color: var(--pink-ink); font-family: var(--mono); font-weight: 600; }
.term__out { display: grid; }

/* ---------- Arabic + right to left ---------- */
:root[lang="ar"] {
  --font: "Geist", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, "Segoe UI", Tahoma, sans-serif;
  --mono: "Geist Mono", "IBM Plex Sans Arabic", ui-monospace, Menlo, Consolas, monospace;
}
:root[lang="ar"] body.os { font-size: 15.5px; }
/* Letter-spacing and uppercase break Arabic joining. */
:root[lang="ar"] :is(.mono, .wallpaper__claim, .edit-toggle, .start__claim, .eco-toolbar__dirty, .legend__hint, .doc__hint) { letter-spacing: 0; text-transform: none; }
:root[lang="ar"] .c-node .c-type, :root[lang="ar"] .c-zone text { letter-spacing: 0; }
:root[lang="ar"] .prose h1, :root[lang="ar"] .lock__time { letter-spacing: 0; }
.term, .eco__svg, .input--code, .leave__url { direction: ltr; }

/* ---------- phone: homescreen + dock ---------- */
@media (max-width: 759px) {
  :root { --taskbar-h: 0px; }
  .statusbar {
    display: flex; position: fixed; top: 0; left: 0; right: 0; z-index: 900; height: 40px;
    align-items: center; justify-content: space-between; padding: 0 22px;
    font-size: 0.82rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--wall-ink); text-shadow: var(--wall-shadow);
  }
  .statusbar__right { display: flex; align-items: center; gap: 8px; font-weight: 500; }
  .statusbar svg { width: 22px; height: 20px; }
  .desktop {
    inset: 40px 0 0 0; padding: 18px 14px 120px; overflow-y: auto;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 6px; align-content: start;
  }
  .desktop .icon { position: static; width: auto; padding: 4px 2px; }
  .desktop .icon__img { width: 56px; height: 56px; }
  .wallpaper__claim { bottom: 104px; }
  .taskbar {
    left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); height: 68px; padding: 0 10px;
    border: 1px solid var(--glass-line); border-radius: 24px; justify-content: space-between;
  }
  .task-list, .tray-clock #clock-date { display: none !important; }
  .edit-toggle { min-width: 44px; padding: 0; justify-content: center; }
  .edit-toggle__label { display: none; }
  .edit-banner { top: 46px; font-size: 0.7rem; border-radius: 12px; }
  .is-editmode .desktop .icon { border-style: dashed; }
  .settings__row { grid-template-columns: 1fr; }
  .leave { width: calc(100vw - 24px); }
  /* Language tabs + Save/Cancel don't fit one row on a phone: force Save/Cancel onto their own row. */
  .doc__editbar, .props__actions { flex-wrap: wrap; }
  .doc__editbar .grow { flex-basis: 100%; height: 0; }
  .task-start { width: 48px; height: 48px; }
  .task-start svg { width: 30px; height: 30px; }
  .tray { flex: 1; justify-content: space-around; }
  .tray-btn { height: 48px; min-width: 44px; }
  .tray-btn svg { width: 24px; height: 24px; }
  .win-layer { inset: 0; z-index: 1100; }
  .win {
    left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important;
    border: 0; border-radius: 0; resize: none; min-width: 0;
    animation: app-in 0.26s var(--ease);
  }
  @keyframes app-in { from { opacity: 0; transform: scale(0.96); } }
  .win__bar { height: 52px; padding-top: env(safe-area-inset-top); }
  .win__btn--min, .win__btn--max { display: none; }
  .win__btn--close { width: 44px; height: 40px; }
  .flyout, .flyout--wide { left: 8px !important; right: 8px !important; bottom: 92px !important; width: auto; max-height: calc(100dvh - 120px); }
  .editor { position: fixed; left: 0; right: 0; bottom: 0; width: auto; height: 62vh; z-index: 5; border-inline-start: 0; border-top: 1px solid var(--line); }
  .ecowin__top { padding: 10px 12px; }
  .toasts { bottom: 96px; }
  .lock { padding: 16vh 20px 88px; }
  .lock__swipe { display: inline; }
  .lock__other { bottom: max(24px, env(safe-area-inset-bottom)); }
}
