/* Copyright (C) Konstantin Khait, Squirrel Wisdom Academy, 2026 */
/* The editor's palette is Caroline's (caroline/Windows/Caroline/wwwroot/chat.css). */
/* The themes. Light is the editor's own (Caroline's palette); dark takes the colours of the splash (navy, gold, cream) and is the default; the page sets
   data-theme on <html> (index.html, before the first paint; Settings > Dark theme / Light theme in main.js). */
:root { --brand: #5066C9; --brand-light: #88AADD; --bg: #f3f4fb; --panel: #ffffff; --line: #e2e4f0; --line2: #d3d6ea; --text: #222; --dim: #6b7290; --soft: #eef0fb; --danger: #d92c2c;
  --bar: #5066C9; --bar-line: #88AADD; --accent: #5066C9; --accent-fg: #fff; --link: #5066C9; --ok: #2e8b4a; --sel: #dde0f7; --field: #fff; --pop: #fff; --pop-line: #ccd; --pop-hover: #eef;
  --tabs: #3A3F8F; --tab-active: #4169E1; --btn: #e2e4f0; --btn-fg: #333; --shadow: #1a1f4a33; --veil: rgba(20, 24, 50, .5); --mark: #fff; }
:root[data-theme=dark] { color-scheme: dark; --brand: #d4a336; --brand-light: #e8c066; --bg: #081b33; --panel: #0b2240; --line: #17314f; --line2: #26496e; --text: #e8edf7; --dim: #8fa3c4; --soft: #12304f; --danger: #ff7a7a;
  --bar: #0c2640; --bar-line: #d4a336; --accent: #d4a336; --accent-fg: #1c1405; --link: #e8c066; --ok: #5fd08a; --sel: #1a416b; --field: #06182d; --pop: #0d2745; --pop-line: #26496e; --pop-hover: #16385c;
  --tabs: #0a2038; --tab-active: #16406a; --btn: #17314f; --btn-fg: #e8edf7; --shadow: #00000066; --veil: rgba(2, 10, 22, .65); --mark: #d4a336; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 "Segoe UI", Helvetica, Arial, sans-serif; }
[hidden] { display: none !important; }
#app { display: flex; flex-direction: column; height: 100%; }

/* menu: the top of the project manager only */
#menubar { display: flex; gap: 2px; background: var(--bar); color: #fff; border-bottom: 3px solid var(--bar-line); padding: 4px 8px; position: relative; z-index: 20; flex: none; flex-wrap: wrap; }
.menu { position: relative; }
.menu > button { background: none; border: 0; color: #fff; padding: 5px 10px; cursor: pointer; border-radius: 6px; font: inherit; }
.menu > button:hover, .menu.open > button { background: #ffffff30; }
.menu .items { display: none; position: absolute; top: 100%; left: 0; min-width: 260px; background: var(--pop); border: 1px solid var(--pop-line); border-radius: 8px; padding: 4px; box-shadow: 0 8px 24px var(--shadow); }
.menu.open .items { display: block; }
.menu .items button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 6px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
.menu .items button:hover:not(:disabled) { background: var(--soft); }
.menu .items button:disabled { color: var(--dim); cursor: default; }
.menu .items button[hidden] { display: none; }
.menu .items hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

#zones { flex: 1; display: flex; min-height: 0; }
#zones > section { display: flex; flex-direction: column; min-width: 120px; min-height: 0; background: var(--bg); }
.splitter { width: 5px; cursor: col-resize; background: var(--line); flex: none; }
.splitter:hover, .splitter.drag { background: var(--brand-light); }
.bar { display: flex; align-items: center; gap: 6px; padding: 4px 8px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.bar .grow, .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button, select, input, textarea { font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--line2); border-radius: 6px; padding: 3px 8px; }
button { cursor: pointer; } button:hover:not(:disabled) { border-color: var(--accent); } button:disabled { opacity: .5; cursor: default; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

/* viewer: the picture only */
#stage { flex: 1; min-height: 0; position: relative; background: #0d0f16; }
#stage ferret-player { position: absolute; inset: 0; }
/* under the viewer: what happened to the project (the log and the changes of Caroline's turn) */
#activity { flex: none; height: 28%; min-height: 70px; display: flex; flex-direction: column; background: var(--panel); border-top: 1px solid var(--line); }
#log { flex: 1; min-height: 0; overflow: auto; padding: 4px 8px; font: 12px/1.4 ui-monospace, Consolas, monospace; white-space: pre-wrap; }
#log .err { color: var(--danger); } #log .ok { color: var(--ok); }

/* project manager */
#tree { height: 30%; min-height: 80px; overflow: auto; padding: 4px 0; border-bottom: 1px solid var(--line); background: var(--panel); }
#tree .row { padding: 1px 8px; cursor: pointer; white-space: nowrap; user-select: none; }
#tree .row:hover { background: var(--soft); } #tree .row.sel { background: var(--sel); }
#tree .dir { color: var(--dim); }
#code { flex: 1; min-height: 0; background: var(--panel); }
.statusbar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 14px; font-size: 12px; color: var(--dim); background: var(--bg); border-top: 1px solid var(--line); min-height: 26px; }
.statusbar-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.statusbar-text.err { color: var(--danger); } .statusbar-text.ok { color: var(--ok); }
.statusbar-cat { flex: none; max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.statusbar-cat.err { color: var(--danger); } .statusbar-cat.ok { color: var(--ok); }
.statusbar-lamps { flex: none; display: flex; align-items: center; gap: 7px; }
.lamp { width: 9px; height: 9px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px #00000014 inset; }
.lamp-red { background: #e0453f; } .lamp-yellow { background: #e0b23f; } .lamp-green { background: #3fb95a; }

/* Caroline's zone: her own chat page in a frame, and below it the files of her last turn */
#chat { background: var(--panel); }
#chat { position: relative; }
/* her shell's tab strip (caroline_shell.py TAB_STRIP_CSS) */
#caroline-tabs { display: flex; flex-wrap: wrap; background: var(--tabs); flex: none; }
#caroline-tabs .tab-header { display: flex; }
#caroline-tabs button { background: transparent; color: #fff; border: 0; border-radius: 0; padding: 6px 10px; font: inherit; cursor: pointer; }
#caroline-tabs .tab-header.active button { background: var(--tab-active); }
:root[data-theme=dark] #caroline-tabs .tab-header.active button { box-shadow: inset 0 -2px 0 var(--accent); }
#caroline-tabs button:hover { background: rgba(255,255,255,.08); }
#caroline-tabs button:disabled { opacity: .5; cursor: default; }
#caroline-tabs .menu { padding: 6px 8px 6px 2px; }
#caroline-tabs input.rename { min-width: 60px; width: 110px; margin: 3px; font: inherit; }
#caroline-frames { flex: 1; min-height: 0; display: flex; }
.caroline-frame { flex: 1; min-height: 0; width: 100%; border: 0; background: var(--panel); }
.caroline-frame[hidden] { display: none; }
#caroline-tab-menu { position: absolute; z-index: 20; min-width: 170px; background: var(--pop); border: 1px solid var(--pop-line); box-shadow: 0 4px 14px rgba(0,0,0,.18); padding: 4px 0; }
#caroline-tab-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 6px 14px; font: inherit; cursor: pointer; }
#caroline-tab-menu button:hover:not(:disabled) { background: var(--pop-hover); }
#caroline-tab-menu button:disabled { color: var(--dim); cursor: default; }
#caroline-tab-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
#caroline-changes { flex: none; display: flex; flex-direction: column; gap: 4px; padding: 8px; background: var(--panel); border-bottom: 1px solid var(--line); max-height: 60%; overflow: auto; }
#caroline-changes button { text-align: left; background: var(--soft); border-color: transparent; }
#caroline-changes button.redo { background: var(--accent); color: var(--accent-fg); }
#caroline-changes button.undo { background: none; border-color: var(--line2); color: var(--dim); }

/* dialogs */
#modal { position: fixed; inset: 0; background: var(--veil); display: flex; align-items: center; justify-content: center; z-index: 50; }
#modal .box { background: var(--bg); border-radius: 12px; padding: 20px; min-width: 360px; max-width: 80vw; max-height: 85vh; overflow: auto; box-shadow: 0 8px 28px #00000040; }
#modal .box.wide { width: min(1100px, 92vw); max-width: 92vw; height: min(760px, 88vh); max-height: 88vh; display: flex; flex-direction: column; }
#modal .box.wide .examples { flex: 1; min-height: 0; display: flex; gap: 16px; }
.ex-tabs { flex: none; width: 250px; display: flex; flex-direction: column; gap: 2px; overflow: auto; border-right: 1px solid var(--line); padding-right: 10px; }
.ex-tabs button { text-align: left; border: 1px solid transparent; background: none; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.ex-tabs button[aria-selected=true] { background: var(--sel); border-color: var(--accent); font-weight: 600; }
.ex-pane { flex: 1; min-width: 0; overflow: auto; font-size: 14px; line-height: 1.5; }
.ex-pane h3 { margin: 0 0 6px; font-size: 20px; } .ex-pane h4 { margin: 14px 0 4px; font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; } .ex-pane p { margin: 8px 0; }
.ex-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; } .ex-tags span { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line2); color: var(--dim); }
.ex-big { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line2); background: var(--field); margin: 0 0 8px; }
.ex-strip { display: flex; gap: 8px; margin: 0 0 12px; } .ex-strip img { width: 25%; aspect-ratio: 5 / 2; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; opacity: .7; } .ex-strip img[aria-selected=true] { border-color: var(--accent); opacity: 1; }
.ex-controls { white-space: pre-line; font-size: 13px; color: var(--dim); }
.ex-size { margin-top: 12px; font-size: 12px; color: var(--dim); }
@media (max-width: 820px) { #modal .box.wide { height: 92vh; } #modal .box.wide .examples { flex-direction: column; } .ex-tabs { width: auto; flex-direction: row; overflow-x: auto; border-right: 0; padding: 0 0 8px; border-bottom: 1px solid var(--line); } .ex-tabs button { white-space: nowrap; } }
#modal h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
#modal label { display: flex; gap: 8px; align-items: center; margin: 6px 0; } #modal label span { width: 140px; color: var(--dim); }
#modal label input:not([type=checkbox]), #modal label select, #modal label textarea { flex: 1; }
#modal .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#modal .buttons button { border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px; background: var(--btn); color: var(--btn-fg); }
#modal .buttons button[type=submit] { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
#modal table { border-collapse: collapse; width: 100%; } #modal td, #modal th { padding: 2px 8px; text-align: left; border-bottom: 1px solid var(--line); }

/* the splash and the sign-in: the Ferret mark's colours (navy, gold, cream) with the ferret-demiurge's pictures (brand/) */
:root { --navy: #081b33; --navy2: #0c2640; --gold: #d4a336; --gold2: #e8c066; --cream: #f3e7c9; }
#splash { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: radial-gradient(ellipse at 50% 42%, #0d2748 0%, var(--navy) 66%); color: var(--cream); transition: opacity .45s ease; }
#splash.gone { opacity: 0; pointer-events: none; }
#splash .splash-art { width: min(80vw, 100vh, 960px); height: auto; margin-bottom: -6vh; -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 58%, transparent 100%); mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 58%, transparent 100%); animation: splash-float 5s ease-in-out infinite; }
#splash .splash-title { font: 800 clamp(28px, 5vh, 52px)/1 "Segoe UI", Helvetica, Arial, sans-serif; letter-spacing: .34em; padding-left: .34em; color: var(--gold); text-shadow: 0 2px 22px #d4a33655; }
#splash .splash-sub { font: 400 clamp(13px, 2vh, 18px)/1.3 "Segoe UI", Helvetica, Arial, sans-serif; letter-spacing: .06em; color: #b9c4dd; }
#splash .splash-bar { width: min(280px, 50vw); height: 3px; margin-top: 18px; border-radius: 3px; background: #ffffff1f; overflow: hidden; }
#splash .splash-bar i { display: block; width: 40%; height: 100%; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--gold), transparent); animation: splash-run 1.3s ease-in-out infinite; }
@keyframes splash-run { from { transform: translateX(-110%); } to { transform: translateX(260%); } }
@keyframes splash-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

#signin { position: fixed; inset: 0; overflow: auto; display: flex; align-items: center; justify-content: flex-end; padding: 32px clamp(20px, 6vw, 110px); font-size: 15px; color: var(--cream);
  background: var(--navy) url(brand/ferret-world.webp) left center / auto 100% no-repeat; }
#signin[hidden] { display: none; }
#signin::before { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, transparent 52%, #081b33cc 100%); }
#signin form { position: relative; width: min(100%, 410px); display: flex; flex-direction: column; gap: 12px; padding: 28px 30px 24px; border-radius: 18px; border: 1px solid #d4a33644; background: #0a2038d9; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 18px 60px #00000080, inset 0 1px 0 #ffffff10; }
#signin .signin-brand { display: flex; align-items: center; gap: 14px; }
#signin .signin-brand img { border-radius: 14px; box-shadow: 0 0 0 1px #d4a33666, 0 6px 20px #00000066; }
#signin h1 { margin: 0; font: 800 22px/1.1 "Segoe UI", Helvetica, Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
#signin .signin-brand span { display: block; margin-top: 4px; font-size: 13px; color: #9fb0d2; letter-spacing: .03em; }
#signin h2 { margin: 6px 0 0; font: 600 20px/1.2 "Segoe UI", Helvetica, Arial, sans-serif; color: #fff; }
#signin .signin-lead { margin: 0; font-size: 13.5px; line-height: 1.45; color: #aebbd6; }
#signin label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #c3cde3; }
#signin input { font: inherit; font-size: 15px; padding: 10px 12px; color: #fff; background: #04101f99; border: 1px solid #ffffff26; border-radius: 10px; color-scheme: dark; }
#signin input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px #d4a33633; }
#signin input:-webkit-autofill { -webkit-text-fill-color: #fff; box-shadow: 0 0 0 40px #0a2038 inset; }
#signin button { font: inherit; padding: 11px; cursor: pointer; background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #1c1405; font-weight: 700; letter-spacing: .02em; border: none; border-radius: 10px; box-shadow: 0 6px 18px #d4a33644; transition: transform .12s, box-shadow .12s, filter .12s; }
#signin button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 9px 24px #d4a33666; }
#signin button:disabled { opacity: .6; cursor: default; }
#signin button.link { background: none; box-shadow: none; transform: none; filter: none; color: var(--gold2); font-weight: 600; padding: 0; border-radius: 0; text-decoration: underline; text-underline-offset: 3px; }
#signin .signin-switch { margin: 2px 0 0; font-size: 14px; color: #aebbd6; text-align: center; }
#signin-error { color: #ff8a8a; min-height: 1.2em; margin: 0; font-size: 13.5px; }
@media (max-width: 900px) {
  #signin { align-items: flex-end; justify-content: center; background-size: 100% auto; background-position: center top; }
  #signin::before { background: linear-gradient(180deg, transparent 26%, #081b33 46%); }
}

#modal .login { max-width: 460px; font-size: 14px; }
#modal .login a { word-break: break-all; color: var(--link); }
#modal .login .devcode { font: 600 26px/1.2 Consolas, monospace; letter-spacing: 2px; text-align: center; margin: 12px 0; user-select: all; }
#modal .login .err { color: var(--danger); }

/* a narrow screen (a phone): one zone at a time, chosen on the tab bar at the bottom; the menu is moved to the top of the page (main.js narrowLayout) */
#tabbar { display: none; }
@media (max-width: 820px) {
  #app { height: 100dvh; }
  #menubar { padding: 4px 6px; }
  .menu { position: static; }
  .menu > button { padding: 9px 11px; }
  .menu .items { left: 8px; right: 8px; min-width: 0; max-height: 70vh; overflow: auto; }
  .menu .items button { padding: 11px 12px; }
  #zones { display: block; position: relative; }
  #zones > .splitter { display: none; }
  #zones > section { display: none; position: absolute; inset: 0; min-width: 0; flex: none !important; }
  #zones[data-tab=viewer] > #viewer, #zones[data-tab=manager] > #manager, #zones[data-tab=chat] > #chat { display: flex; }
  #tabbar { display: flex; flex: none; background: var(--bar); border-top: 3px solid var(--bar-line); padding-bottom: env(safe-area-inset-bottom); }
  #tabbar button { flex: 1; background: none; border: 0; border-radius: 0; color: #ffffffb8; padding: 13px 6px; font-size: 15px; font-weight: 600; }
  #tabbar button[aria-selected=true] { color: #fff; background: #ffffff26; box-shadow: inset 0 3px 0 var(--mark); }
  #modal .box { min-width: 0; width: 92vw; max-width: 92vw; padding: 16px; }
  #modal label { flex-wrap: wrap; } #modal label span { width: 100%; }
}
