/* CAISSA GIF Studio — isolated board-first workspace (HEAD / BODY / FOOT). */
.gif-studio-page { background: #0b111b; color: #e8edf5; }
.gif-studio-page *, .gif-studio-page *::before, .gif-studio-page *::after { box-sizing: border-box; }
.gif-studio-page :is(button, input, select, textarea, a):focus-visible { outline: 3px solid #8fc0ff; outline-offset: 2px; }
.gif-studio-page :is([hidden], progress[hidden]) { display: none !important; }
.gif-skip { position: absolute; left: -9999px; top: 0; z-index: 9000; background: #fff; color: #111; padding: 12px; }
.gif-skip:focus { left: 10px; }
.gif-layout { min-height: 100vh; }
.gif-main.caissa-standalone-content { min-width: 0; padding: 22px clamp(14px, 2.4vw, 36px) 46px; background: radial-gradient(circle at 25% 0%, #152237 0, #0b111b 52%); }
.gif-page-header { max-width: 1290px; margin: 0 auto 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.gif-page-header h1 { font-size: clamp(26px, 2.7vw, 35px); line-height: 1.15; margin: 4px 0 8px; letter-spacing: -.6px; color: #f6f7f9; }
.gif-page-header h1 span { font-size: 12px; color: #c1d8b0; background: #263e2a; padding: 4px 8px; border-radius: 16px; vertical-align: middle; letter-spacing: .2px; }
.gif-kicker { font-size: 12px; font-weight: 700; letter-spacing: 1.7px; text-transform: uppercase; color: #b0c6a0; margin: 0; }
.gif-tagline { font-size: 14px; color: #b5c1d0; margin: 0; }
.gif-private { color: #bfd4b9; font-size: 12px; border: 1px solid #365445; border-radius: 30px; padding: 9px 13px; white-space: nowrap; }
.gif-private i { margin-right: 7px; }
.gif-workspace { max-width: 1290px; margin: 0 auto; display: grid; grid-template-columns: minmax(0,1fr) minmax(330px,420px); gap: clamp(18px,2.3vw,32px); align-items: start; }
.gif-board-region { min-width: 0; width: 100%; max-width: 640px; justify-self: center; }
.gif-board-head { min-height: 46px; padding: 4px 2px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.gif-players { min-width: 0; display: flex; align-items: center; gap: 9px; font-size: clamp(12px,1.4vw,16px); font-weight: 650; }
.gif-players > span:not(.gif-versus) { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; max-width: 185px; }
.gif-versus { color: #90a2b6; font-size: 12px; font-weight: 400; }
.gif-result { flex: 0 0 auto; color: #c8d3e0; font-size: 14px; }
.gif-board-wrap { width: 100%; aspect-ratio: 1; border: 1px solid #3a4656; border-radius: 8px; overflow: hidden; background: #699255; box-shadow: 0 12px 34px rgba(0,0,0,.22); }
.gif-board-wrap canvas { display: block; width: 100%; height: 100%; }
.gif-board-note { min-height: 36px; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; color: #b6c1d0; }
.gif-replay { display: flex; align-items: stretch; justify-content: center; gap: 8px; width: 100%; margin-top: 6px; }
.gif-replay button { cursor: pointer; width: 48px; height: 44px; color: #d6e0ee; border: 1px solid #39495e; background: #182335; border-radius: 8px; }
.gif-replay .gif-play { width: 108px; display: flex; align-items: center; justify-content: center; gap: 10px; border-color: #52784b; color: #eff8eb; background: #315b38; font-weight: 700; }
.gif-replay button:disabled { cursor: not-allowed; color: #657285; opacity: .75; }
.gif-replay button:not(:disabled):hover { border-color: #93b6d8; filter: brightness(1.1); }
.gif-position-range { display: flex; align-items: center; gap: 16px; margin-top: 13px; color: #b7c3d4; font-size: 12px; }
.gif-position-range label { white-space: nowrap; }
.gif-position-range input { flex: 1; accent-color: #85b46e; cursor: pointer; min-width: 0; }
.gif-position-range input:disabled { opacity: .45; }
.gif-panel { display: flex; flex-direction: column; min-width: 0; min-height: min(672px, calc(100vh - 155px)); max-height: 780px; border: 1px solid #304052; border-radius: 12px; background: #131d2c; overflow: hidden; box-shadow: 0 8px 25px rgba(0,0,0,.17); }
.gif-panel-head { flex: 0 0 auto; padding: 12px 14px 0; border-bottom: 1px solid #344256; }
.gif-tabs { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.gif-tabs button { min-height: 43px; color: #b6c4d6; border: 0; border-bottom: 3px solid transparent; background: transparent; cursor: pointer; font-size: 13px; font-weight: 650; }
.gif-tabs button[aria-selected="true"] { color: #f0f6ed; border-bottom-color: #8ec17b; }
.gif-tabs button:hover { color: #fff; background: #223247; }
.gif-panel-body { flex: 1 1 auto; min-height: 0; padding: 24px 22px; overflow: auto; overscroll-behavior: contain; }
.gif-panel-body h2 { font-size: 19px; font-weight: 700; margin: 0 0 10px; color: #f0f4fb; }
.gif-help { color: #b4c0d0; font-size: 13px; line-height: 1.65; margin: 0 0 19px; }
.gif-panel-body label:not(.gif-button) { display: block; margin: 15px 0 7px; color: #e4eaf2; font-size: 13px; font-weight: 650; }
.gif-panel-body :is(textarea, select, input[type="number"]) { width: 100%; background: #0e1726; border: 1px solid #526077; border-radius: 7px; color: #f1f4f8; padding: 11px 12px; font-size: 13px; }
.gif-panel-body select { min-height: 43px; cursor: pointer; }
.gif-panel-body textarea { min-height: 230px; max-height: 330px; resize: vertical; line-height: 1.55; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.gif-panel-body textarea::placeholder { color: #8190a2; }
.gif-import-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-top: 13px; }
.gif-button { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border-radius: 7px; border: 1px solid transparent; min-height: 42px; padding: 10px 14px; color: #edf5f3; font-size: 13px; font-weight: 750; text-decoration: none; cursor: pointer; line-height: 1.2; }
.gif-button-primary { background: #558e48; border-color: #71ac61; color: #fff; }
.gif-button-primary:hover:not(:disabled) { background: #669f59; }
.gif-button-subtle { background: #233248; border-color: #506179; }
.gif-button-subtle:hover { background: #2e3e52; }
.gif-button:disabled { opacity: .55; cursor: not-allowed; }
.gif-link-button { border: 0; background: transparent; color: #b6d5ff; padding: 10px 0 0; font-size: 13px; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.gif-link-button:hover { color: #fff; }
.gif-fineprint { color: #98aabd; font-size: 12px; line-height: 1.55; margin: 14px 0 0; }
.gif-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gif-panel-foot { flex: 0 0 auto; border-top: 1px solid #354359; background: #101a2a; padding: 13px 20px 17px; }
.gif-status { font-size: 12px; line-height: 1.5; color: #bbcadc; margin: 0 0 12px; min-height: 20px; }
.gif-status.is-error { color: #ffb3a8; }
.gif-panel-foot progress { display: block; width: 100%; height: 7px; accent-color: #82bc73; margin: 0 0 12px; }
.gif-create, .gif-button-download { width: 100%; font-size: 15px; min-height: 47px; }
.gif-button-download { background: #253d30; border-color: #58835e; margin-top: 8px; }
.gif-button-download:hover { background: #33543d; }
.gif-about { max-width: 1290px; margin: 38px auto 0; padding: 22px 0; border-top: 1px solid #283b50; }
.gif-about h2 { font-size: 16px; margin: 0 0 8px; }
.gif-about p { color: #9cabc0; max-width: 700px; font-size: 13px; line-height: 1.65; margin: 0; }
@media (max-width: 1130px) {
  .gif-workspace { grid-template-columns: minmax(0,1fr) minmax(320px,380px); gap: 18px; }
  .gif-panel-body { padding: 18px; }
}
@media (max-width: 930px) {
  .gif-workspace { grid-template-columns: 1fr; max-width: 690px; }
  .gif-page-header { max-width: 690px; }
  .gif-panel { min-height: 510px; max-height: none; }
  .gif-panel-body { overflow: visible; }
  .gif-board-region { max-width: 610px; }
}
@media (max-width: 600px) {
  .gif-main.caissa-standalone-content { padding: 64px 12px 28px; }
  .gif-page-header { display: block; margin-bottom: 12px; }
  .gif-private { display: inline-flex; margin-top: 12px; }
  .gif-panel { min-height: 500px; }
  .gif-panel-body { padding: 15px; }
  .gif-import-actions .gif-button { flex: 1; }
  .gif-board-head { padding: 5px 0; }
  .gif-players { gap: 5px; }
  .gif-players > span:not(.gif-versus) { max-width: 125px; }
  .gif-replay { gap: 5px; }
  .gif-replay button { flex: 1; width: auto; }
  .gif-replay .gif-play { flex: 1.8; width: auto; }
  .gif-field-grid { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) { .gif-studio-page * { scroll-behavior: auto !important; } }

/* v1.1 — four-tab studio with one scroll owner and a nonmoving right FOOT. */
.gif-workspace { align-items: start; }
.gif-panel {
  height: clamp(640px, calc(100dvh - 170px), 790px);
  min-height: 0;
  max-height: none;
}
.gif-panel-head { flex-shrink: 0; }
.gif-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
.gif-tabs button { min-width: 0; padding: 9px 2px; font-size: 12px; line-height: 1.2; }
.gif-panel-body { flex: 1 1 auto; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.gif-panel-body :is(input[type="text"], textarea, select, input[type="number"]) {
  width: 100%; min-width: 0; background: #0e1726; border: 1px solid #526077;
  border-radius: 7px; color: #f1f4f8; padding: 10px 11px; font-size: 13px;
}
.gif-panel-body input[type="text"] { min-height: 43px; font-family: ui-monospace, Consolas, monospace; }
.gif-load-fen { margin-top: 10px; }
.gif-panel-foot { flex: 0 0 auto; position: relative; z-index: 1; padding: 10px 16px 13px; background: #101a2a; }
.gif-foot-replay { border-bottom: 1px solid #304158; padding-bottom: 11px; margin-bottom: 10px; }
.gif-replay { margin-top: 0; justify-content: space-between; gap: 7px; }
.gif-replay button { flex: 1; min-width: 0; width: auto; height: 38px; }
.gif-replay .gif-play { flex: 1.65; width: auto; }
.gif-position-range { margin-top: 10px; gap: 12px; }
.gif-status { min-height: 20px; margin-bottom: 8px; font-size: 11.5px; }
.gif-create, .gif-button-download { min-height: 43px; }
.gif-board-wrap { position: relative; }
.gif-board-wrap.is-interactive canvas { touch-action: none; cursor: crosshair; }
.gif-drag-piece {
  position: absolute; z-index: 4; display: grid; place-items: center;
  pointer-events: none; user-select: none; touch-action: none; will-change: transform;
  transform: translate3d(0,0,0); transition: none !important;
  box-shadow: none !important; filter: none !important;
}
.gif-drag-piece img { display: block; width: 84%; height: 84%; object-fit: contain; }
.gif-drag-piece span { font-size: clamp(25px, 4.2vw, 52px); line-height: 1; }
.gif-drag-piece span.is-white { color: #f9fbf9; -webkit-text-stroke: 1px #243143; }
.gif-drag-piece span.is-black { color: #202634; -webkit-text-stroke: 1px #eff5e5; }
.gif-board-guide { color: #b6c1d0; font-size: 11px; line-height: 1.5; margin: 7px 0; }
.gif-tool-palette, .gif-castling { padding: 10px; border: 1px solid #33475e; border-radius: 8px; margin: 13px 0; }
.gif-tool-palette legend, .gif-castling legend { color: #d5e0ed; font-size: 12px; font-weight: 700; padding: 0 4px; }
.gif-tool-row { display: flex; gap: 8px; margin-bottom: 13px; }
.gif-tool-row button { flex: 1; min-height: 42px; color: #dce5f0; background: #26354a; border: 1px solid #50627a; border-radius: 7px; cursor: pointer; }
.gif-tool-row button.is-selected { border-color: #a4d690; background: #32563b; }
.gif-palette-group { display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 9px; }
.gif-palette-group > span { color: #c3d0dc; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.gif-palette-pieces { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.gif-palette-pieces button { min-width: 0; min-height: 40px; padding: 2px; background: #2c3c50; border: 1px solid #485c73; border-radius: 6px; cursor: pointer; }
.gif-palette-pieces button img { display: block; width: 100%; max-width: 42px; margin: auto; aspect-ratio: 1; object-fit: contain; }
.gif-palette-pieces button.is-selected { border-color: #a4d690; background: #355b3b; }
.gif-castling { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gif-castling legend { grid-column: 1/-1; }
.gif-panel-body .gif-castling label { margin: 0; font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.gif-castling input { accent-color: #89bd7b; }
.gif-setup-row { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 10px; align-items: center; }
.gif-panel-body .gif-setup-row label { margin: 0; }
.gif-preset-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.gif-board-selection { color: #c2d3e8; background: #1c2c40; border-left: 3px solid #88b773; margin: 14px 0; padding: 9px 11px; font-size: 12px; line-height: 1.55; }
.gif-setup-fen-wrap { margin: 13px 0; }
.gif-panel-body .gif-setup-fen-wrap label { margin-bottom: 6px; }
.gif-setup-fen-wrap output { display: block; white-space: normal; overflow-wrap: anywhere; background: #0c1524; border: 1px solid #37495e; border-radius: 6px; padding: 9px; color: #b9d8f2; font: 11px/1.6 ui-monospace, Consolas, monospace; }
.gif-notation-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-top: 18px; border-top: 1px solid #33475e; padding-top: 12px; }
.gif-notation-head h3 { margin: 0; font-size: 15px; }
.gif-notation-head span { color: #a6b9d0; font-size: 11px; }
.gif-move-list { display: flex; flex-wrap: wrap; align-items: start; gap: 6px; padding: 10px 0; }
.gif-move-chip { color: #e6eef7; background: #24354a; border: 1px solid #455771; border-radius: 6px; padding: 7px 9px; cursor: pointer; font: 12px/1.3 ui-monospace, Consolas, monospace; }
.gif-move-chip[aria-current="true"] { color: #fff; background: #427240; border-color: #a0cd82; }
.gif-move-chip:hover { border-color: #a6bfd8; }
.gif-setup-record .gif-import-actions { margin: 0; }
@media (max-width: 930px) {
  .gif-panel { height: 690px; min-height: 0; max-height: none; }
  .gif-panel-body { overflow-y: auto; overflow-x: hidden; }
}
@media (max-width: 600px) {
  .gif-panel { height: 655px; min-height: 0; max-height: none; }
  .gif-tabs button { font-size: 11px; padding-inline: 2px; }
  .gif-panel-foot { padding: 10px 12px 12px; }
  .gif-replay button { height: 40px; }
  .gif-palette-group { grid-template-columns: 33px minmax(0,1fr); gap: 5px; }
  .gif-palette-pieces button { min-height: 37px; }
}
