:root{color-scheme:light;--forest:#233d34;--deep:#13271f;--mid:#355b48;--cream:#f5eedc;--paper:#fff8e9;--copper:#aa7844;--ink:#302d24;--border:#b7a17c}
*{box-sizing:border-box}html,body{min-height:100%;margin:0}
body{font:18px/1.45 'Forum',Georgia,serif;color:var(--ink);background:radial-gradient(ellipse at 50% 10%,#cfbc91,transparent 56%),linear-gradient(135deg,#173127,#4b4632 50%,#122922)}
button,textarea{font:19px/1.35 'Neucha','Forum',serif}button{cursor:pointer}
button:focus-visible,textarea:focus-visible,a:focus-visible{outline:3px solid #ae7839;outline-offset:3px}
.sr-only{position:absolute;clip:rect(0,0,0,0);width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;border:0;white-space:nowrap}
.shell{width:min(1220px,calc(100% - 40px));height:min(910px,calc(100dvh - 44px));min-height:560px;display:grid;grid-template-columns:345px minmax(0,1fr);margin:22px auto;overflow:hidden;background:var(--cream);border:1px solid #af915f;box-shadow:0 28px 90px #081b16a6,0 0 0 5px #183025,0 0 0 6px #ad8651}
.side{color:#faeccf;position:relative;isolation:isolate;min-width:0;display:flex;flex-direction:column;justify-content:space-between;padding:32px 26px 25px;border-right:4px double #bb965e;background:var(--deep)}
.side:before{position:absolute;content:"";inset:0;z-index:-2;background:url('./sanko-oselya-sidebar.webp') center center/cover no-repeat;background-color:#183428}
.side:after{position:absolute;content:"";inset:0;z-index:-1;background:linear-gradient(180deg,#10271dd9 0%,#122b20b8 24%,#172c2485 50%,#10261ddc 100%)}
.side-head{text-align:center;position:relative}.eyebrow{font:13px/1.3 'Forum',serif;color:#ebca8d;letter-spacing:.11em;margin:0}
.ornament{margin:12px 0 19px;color:#ccab70;font-size:18px;letter-spacing:.13em}
.portrait{width:210px;height:237px;margin:0 auto 18px;border-radius:105px 105px 7px 7px;border:4px double #dcbd7f;box-shadow:0 0 0 5px #17251daa,0 0 0 6px #dcb06c6e,0 16px 30px #0009;display:flex;align-items:center;justify-content:center;flex-direction:column;background:radial-gradient(ellipse at 50% 28%,#648268a1,#294d39df 63%,#142a22);color:#e2d2a4;overflow:hidden}
.portrait img{display:block;width:100%;height:100%;object-fit:cover;object-position:50% 32%}
.side h1{margin:2px 0 3px;font:400 clamp(49px,5vw,67px)/1.08 'Ruslan Display',Georgia,serif;color:#f7dfb0;text-shadow:0 4px 16px #000b}
.side-sub{font:21px/1.25 'Forum',serif;color:#ebd2a7;margin:8px 0}
.side-bottom{position:relative;text-align:center}.side-quote{font:21px/1.3 'Neucha',serif;text-shadow:0 2px 9px #000;margin:25px 0 32px}
.aside-foot{font:15px/1.35 'Forum',serif;color:#e4d4b4;padding:17px 6px 0;border-top:1px solid #d0ad714f}.aside-foot a{color:#f1ce8b;text-underline-offset:4px;display:inline-block;margin-top:8px}
.chat{position:relative;display:flex;flex-direction:column;min-width:0;min-height:0;background:repeating-linear-gradient(0deg,#69492205 0 1px,transparent 1px 5px),radial-gradient(ellipse at 30% 10%,#fffaee,#f5ecd7 55%,#e7d9b9 100%)}
.chat:before{content:"";pointer-events:none;position:absolute;top:0;bottom:0;left:8px;width:1px;background:#bca67899}
.topbar{z-index:1;display:flex;align-items:center;justify-content:space-between;gap:15px;min-height:98px;padding:16px 31px;border-bottom:3px double #b7a076;background:linear-gradient(180deg,#fcf4e2ed,#eaddbfad)}
.top-identity{display:flex;align-items:center;min-width:0;gap:17px}.emblem{width:54px;height:54px;flex:none;display:grid;place-items:center;color:#efd6a1;font:36px/1 'Forum',serif;background:var(--forest);border:1px solid #b08b54;box-shadow:0 0 0 3px #ead5ad,0 0 0 4px #ab986b}
.emblem img{width:100%;height:100%;display:block;object-fit:cover;object-position:50% 28%}.heading{min-width:0}.kicker{font:13px/1.15 'Forum',serif;color:#7b684b;letter-spacing:.07em}.top-title{font:400 31px/1.15 'Ruslan Display',Georgia,serif;color:#334330;margin:5px 0 2px}.top-sub{font:15px/1.2 'Forum',serif;color:#776650}
.new-chat{border:1px solid #ac936c;background:#fbf1dc;color:#665437;padding:10px 13px;min-height:42px;white-space:nowrap}.new-chat:hover{background:#eee1c5}

.messages{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:17px;padding:24px 36px 25px 37px;scrollbar-color:#b49c70 transparent;scrollbar-width:thin}
.message{max-width:min(88%,660px);display:flex;flex-direction:column;gap:6px;min-width:0}.message.model,.message.notice{align-self:flex-start}.message.user{align-self:flex-end}.byline{padding:0 7px;color:#82643b;font:15px/1.2 'Forum',serif}.message.user .byline{text-align:right;color:#645f51}.message.notice .byline{color:#676955}
.bubble{padding:15px 20px;white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.38;background:linear-gradient(155deg,#fffcf4,#f8edd7);border:1px solid #c3ad85;border-radius:3px 13px 13px 13px;box-shadow:0 3px 0 #b9a17c26,0 8px 24px #7050330e;font:21px/1.35 'Neucha',Georgia,serif}
.message.user .bubble{color:#fff7e9;background:linear-gradient(135deg,#385a44,#203a30);border-color:#7b865f;border-radius:13px 3px 13px 13px}.message.notice .bubble{font:17px/1.35 'Forum',serif;color:#57614a;background:#f0eddf;border-color:#babda0}.message.pending .bubble{color:#877765;font-style:italic}
.error{margin:0 30px 12px;padding:11px 13px;border:1px solid #ae765f;background:#f9e9db;color:#843e2c;font:17px/1.3 'Neucha',serif}.error[hidden]{display:none}
.composer-wrap{z-index:1;flex:none;padding:16px 30px max(17px,env(safe-area-inset-bottom));border-top:3px double #bba57b;background:linear-gradient(0deg,#e7d8b5,#f3e7ce)}
.composer{display:flex;align-items:flex-end;gap:10px}.composer textarea{flex:1;min-width:0;width:100%;min-height:51px;max-height:150px;resize:none;background:#fffaf0;color:#312e24;border:1px solid #b6a080;border-radius:4px;padding:12px 14px;font:20px/1.25 'Neucha',Georgia,serif;box-shadow:inset 0 1px 4px #63491e21}.composer textarea::placeholder{color:#847866}
.send{flex:none;display:grid;place-items:center;width:51px;height:51px;color:#fff0d7;background:#6c4732;border:1px solid #684832;border-radius:4px}.send:hover{background:#503727}.send svg{width:22px;height:22px}
button:disabled,textarea:disabled{opacity:.56;cursor:not-allowed}.composer-note{margin-top:8px;text-align:right;color:#746e5c;font:14px/1.25 'Forum',serif}
.confirm-dialog{width:min(390px,calc(100% - 30px));padding:24px;background:#f5ecda;color:#393324;border:3px double #a78853;box-shadow:0 20px 70px #0008}.confirm-dialog::backdrop{background:#0b281eb5;backdrop-filter:blur(2px)}.dialog-ornament{text-align:center;color:#8b6843;font-size:22px}.confirm-dialog h2{margin:6px 0 7px;text-align:center;font:400 27px/1.15 'Ruslan Display',Georgia,serif}.confirm-dialog p{text-align:center;font:19px/1.35 'Neucha',serif}
.dialog-actions{margin-top:19px;display:flex;justify-content:center;gap:12px}.dialog-actions button{padding:10px 16px;min-width:106px;border:1px solid #a78a63}.cancel{background:#fff7e8;color:#433825}.confirm{background:#385742;color:#fff7e5}
@media(max-width:900px) and (min-width:701px){.shell{grid-template-columns:280px minmax(0,1fr)}.side{padding:27px 18px 19px}.portrait{width:180px;height:200px}.side-quote{font-size:19px}.topbar{padding-left:23px;padding-right:23px}.messages{padding-left:24px;padding-right:24px}}
@media(max-height:730px) and (min-width:701px){.side{padding-top:21px;padding-bottom:17px}.portrait{width:142px;height:155px;margin-bottom:8px}.side h1{font-size:45px}.side-quote{margin:10px 0 15px;font-size:17px}.ornament{margin:6px 0 10px}}
@media(max-width:700px){body{background:#ebdfc6}.shell{display:block;width:100%;height:100dvh;min-height:0;margin:0;border:0;box-shadow:none}.side{display:none}.chat{height:100%;min-height:0}.chat:before{display:none}.topbar{min-height:77px;padding:10px 13px;gap:8px}.emblem{width:42px;height:42px;font-size:28px;box-shadow:0 0 0 2px #ead5ad,0 0 0 3px #ab986b}.top-identity{gap:11px}.kicker{font-size:11px;letter-spacing:.02em}.top-title{font-size:26px;margin-top:2px}.top-sub{font-size:12px}.new-chat{min-height:39px;padding:8px 10px;font-size:16px}.messages{padding:18px 13px 20px;gap:14px}.message{max-width:94%}.bubble{padding:13px 15px;font-size:20px}.composer-wrap{padding:11px 12px max(12px,env(safe-area-inset-bottom))}.composer textarea{min-height:48px;font-size:19px}.send{width:48px;height:48px}.composer-note{font-size:12px}}
@media(max-width:360px){.topbar{padding:8px 10px}.top-title{font-size:23px}.top-sub{display:none}.kicker{font-size:10px}.emblem{width:36px;height:36px}.new-chat{font-size:14px;padding:8px}.new-chat span{display:none}.messages{padding:14px 10px}.bubble{font-size:19px}}
@media(prefers-reduced-motion:no-preference){.bubble{animation:appear .17s ease-out}@keyframes appear{from{opacity:.55;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}}


/* VK Mini App: desktop iframe gets the same two-column layout as the
   standalone chat; narrow or short VK windows keep the chat-only layout.
   Bridge insets and visualViewport still protect the virtual keyboard. */
html.vk-embedded,html.vk-embedded body{height:100%;overflow:hidden}
.vk-embedded body{background:var(--cream)}
.vk-embedded .shell{display:block;width:100%;height:var(--vk-visible-height,100dvh);min-height:0;margin:0;border:0;box-shadow:none}
.vk-embedded .side{display:none}
.vk-embedded .chat{height:100%;min-height:0}
.vk-embedded .topbar{
 padding-top:max(10px,env(safe-area-inset-top,0px),var(--vk-inset-top,0px));
 padding-right:max(13px,env(safe-area-inset-right,0px),var(--vk-inset-right,0px));
 padding-left:max(13px,env(safe-area-inset-left,0px),var(--vk-inset-left,0px))
}
.vk-embedded .messages{
 padding-right:max(13px,env(safe-area-inset-right,0px),var(--vk-inset-right,0px));
 padding-left:max(13px,env(safe-area-inset-left,0px),var(--vk-inset-left,0px))
}
.vk-embedded .composer-wrap{
 padding-right:max(12px,env(safe-area-inset-right,0px),var(--vk-inset-right,0px));
 padding-left:max(12px,env(safe-area-inset-left,0px),var(--vk-inset-left,0px));
 padding-bottom:max(12px,env(safe-area-inset-bottom,0px),var(--vk-inset-bottom,0px))
}
@media(max-height:450px){
 .vk-embedded .topbar{min-height:52px;padding-top:5px;padding-bottom:5px}
 .vk-embedded .kicker,.vk-embedded .top-sub,.vk-embedded .composer-note{display:none}
 .vk-embedded .messages{padding-top:8px;padding-bottom:8px;gap:8px}
 .vk-embedded .composer-wrap{padding-top:7px}
}

/* VK desktop: restore Sanko's existing forest/portrait panel. The breakpoint
   checks the actual iframe viewport, not the full browser window. Narrow and
   short WebViews remain one-column so the composer never loses usable room. */
@media (min-width:800px) and (min-height:560px) {
  .vk-embedded .shell {
    display:grid;
    grid-template-columns:clamp(270px,35%,345px) minmax(0,1fr);
  }
  .vk-embedded .side {
    display:flex;
    min-height:0;
    overflow-y:auto;
    overscroll-behavior:contain;
    padding:clamp(17px,2.6vh,27px) clamp(17px,2.1vw,26px) 17px;
  }
  .vk-embedded .portrait {width:190px;height:213px;margin-bottom:13px}
  .vk-embedded .side h1 {font-size:clamp(43px,4vw,55px)}
  .vk-embedded .ornament {margin:8px 0 13px}
  .vk-embedded .side-quote {margin:12px 0 16px}
  .vk-embedded .chat {height:100%;min-width:0;min-height:0}
  .vk-embedded .topbar {padding-right:20px;padding-left:20px}
  .vk-embedded .messages {padding-right:23px;padding-left:23px}
  .vk-embedded .composer-wrap {padding-right:20px;padding-left:20px}
}
/* Extra height sensitivity: keep a full portrait without pushing the
   bottom of the sidebar out of view in compact desktop VK windows. */
@media (min-width:800px) and (min-height:560px) and (max-height:700px) {
  .vk-embedded .portrait {width:155px;height:174px;margin-bottom:9px}
  .vk-embedded .side h1 {font-size:45px}
  .vk-embedded .side-sub {font-size:18px}
  .vk-embedded .side-quote {font-size:18px;margin:10px 0}
  .vk-embedded .aside-foot {font-size:14px;padding-top:9px}
}
