/* ==========================================================================
   KHARITON.EXE — CLASSIC 1-BIT SKEUOMORPHIC OS DESIGN SYSTEM
   Authentic Macintosh System 7 & Windows 95 Monochrome Interface
   ========================================================================== */

/* 1. Self-Hosted OFL Fonts */
@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/pixelify-sans.woff2') format('woff2');
}

@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/pixelify-sans.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/ibm-plex-mono.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/ibm-plex-mono-600.woff2') format('woff2');
}

@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/playfair-display.woff2') format('woff2');
}

@font-face {
  font-family: 'Playfair Display';
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/playfair-display-italic.woff2') format('woff2');
}

/* 2. Design Tokens */
:root {
  --color-desk: #c0c0c0;
  --color-face: #dfdfdf;
  --color-white: #ffffff;
  --color-light: #ffffff;
  --color-shadow: #808080;
  --color-dark-shadow: #404040;
  --color-black: #000000;
  --text-main: #000000;
  --text-muted: #555555;
  --title-pinstripe: #000000;
  --well-bg: #ffffff;
  --well-text: #000000;
  --selection-bg: #000000;
  --selection-fg: #ffffff;
  --dither-color: #808080;
  --font-ui: "Pixelify Sans", "Chicago", "MS Sans Serif", -apple-system, BlinkMacSystemFont, monospace, sans-serif;
  --font-mono: "IBM Plex Mono", "Monaco", "Courier New", monospace;
  --font-quote: "Playfair Display", "Times New Roman", Georgia, serif;
  --dither-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2'%3E%3Crect width='1' height='1' fill='%23808080'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%23808080'/%3E%3C/svg%3E");
}

/* Dark Noir 1-Bit Inversion */
[data-theme="dark"] {
  --color-desk: #101010;
  --color-face: #1c1c1c;
  --color-white: #4a4a4a;
  --color-light: #333333;
  --color-shadow: #121212;
  --color-dark-shadow: #000000;
  --color-black: #ffffff;
  --text-main: #ffffff;
  --text-muted: #999999;
  --title-pinstripe: #ffffff;
  --well-bg: #0a0a0a;
  --well-text: #ffffff;
  --selection-bg: #ffffff;
  --selection-fg: #000000;
  --dither-color: #2b2b2b;
  --dither-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2'%3E%3Crect width='1' height='1' fill='%232b2b2b'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%232b2b2b'/%3E%3C/svg%3E");
}

/* 3. Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-main);
  user-select: none;
  -webkit-user-select: none;
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-fg);
}

body {
  background-color: var(--color-desk);
  background-image: var(--dither-pattern);
  background-repeat: repeat;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 4. Boot Screen Overlay */
#boot-screen {
  position: fixed;
  inset: 0;
  background-color: var(--color-desk);
  background-image: var(--dither-pattern);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 280ms ease, visibility 280ms;
}

#boot-screen.dismissed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-box {
  width: 320px;
  max-width: 90vw;
  background: var(--color-face);
  border: 2px solid var(--color-black);
  box-shadow: 
    inset 1px 1px 0 var(--color-white),
    inset -1px -1px 0 var(--color-shadow),
    4px 4px 0 rgba(0,0,0,0.5);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.boot-icon {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
}

.boot-title {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.boot-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.boot-bar-container {
  width: 100%;
  height: 14px;
  background: var(--color-white);
  border-top: 1px solid var(--color-shadow);
  border-left: 1px solid var(--color-shadow);
  border-right: 1px solid var(--color-white);
  border-bottom: 1px solid var(--color-white);
  padding: 1px;
  box-shadow: inset 1px 1px 1px rgba(0,0,0,0.3);
}

.boot-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--color-black);
  transition: width 100ms linear;
}

.boot-skip-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* 5. Top System Menubar */
#menubar {
  height: 26px;
  background: var(--color-face);
  border-bottom: 1px solid var(--color-black);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-size: 13px;
  position: relative;
  z-index: 100;
  box-shadow: 0 1px 0 var(--color-white);
  flex-shrink: 0;
}

.menu-left {
  display: flex;
  align-items: center;
  gap: 2px;
}

.menu-item {
  position: relative;
  padding: 2px 8px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.02em;
  touch-action: manipulation;
}

.menu-item:hover,
.menu-item.active {
  background: var(--color-black);
  color: var(--color-white);
}

.menu-apple-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: middle;
  fill: currentColor;
}

.menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--color-face);
  border: 1px solid var(--color-black);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
  min-width: 190px;
  padding: 3px 0;
  z-index: 200;
}

.menu-item.active .menu-dropdown {
  display: block;
}

.dropdown-row {
  padding: 4px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
  font-weight: normal;
  cursor: pointer;
}

.dropdown-row:hover {
  background: var(--color-black);
  color: var(--color-white);
}

.dropdown-divider {
  height: 1px;
  border-top: 1px solid var(--color-shadow);
  border-bottom: 1px solid var(--color-white);
  margin: 3px 0;
}

.dropdown-shortcut {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 12px;
}

.dropdown-row:hover .dropdown-shortcut {
  color: var(--color-white);
}

.menu-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

/* 6. Desktop & Workspace */
#desktop {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
  min-height: 0;
}

.desktop-icons {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 10;
}

.desk-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 86px;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
}

.desk-icon-img {
  width: 38px;
  height: 38px;
  margin-bottom: 4px;
  image-rendering: pixelated;
}

.desk-icon-label {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 2px 4px;
  color: var(--text-main);
  background: transparent;
  white-space: nowrap;
}

.desk-icon:hover .desk-icon-label,
.desk-icon:focus .desk-icon-label {
  background: var(--color-black);
  color: var(--color-white);
}

/* 7. Main Skeuomorphic Window */
.os-window {
  width: 780px;
  min-width: 0;
  max-width: calc(100vw - 12px);
  min-height: 260px;
  max-height: calc(100vh - 36px);
  background: var(--color-face);
  border: 1px solid var(--color-black);
  box-shadow: 
    inset 1px 1px 0px var(--color-white),
    inset -1px -1px 0px var(--color-shadow),
    5px 5px 0px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 20;
  overflow: hidden;
  transition: height 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Window Shade Mode (collapsed to titlebar only) */
.os-window.shaded {
  min-height: 28px !important;
  height: 28px !important;
}

.os-window.shaded .window-body,
.os-window.shaded .window-statusbar {
  display: none !important;
}

.os-window.maximized {
  position: absolute !important;
  left: 4px !important;
  top: 4px !important;
  width: calc(100% - 8px) !important;
  height: calc(100% - 8px) !important;
  max-width: none !important;
  min-height: 0 !important;
  z-index: 50 !important;
}

/* Global Dragging & Resizing States */
body.is-dragging,
body.is-dragging * {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: grabbing !important;
}

body.is-resizing,
body.is-resizing * {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: se-resize !important;
}

/* Pinstripe Titlebar */
.window-titlebar {
  height: 28px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-black);
  position: relative;
  background: repeating-linear-gradient(
    to bottom,
    var(--color-face),
    var(--color-face) 1px,
    var(--title-pinstripe) 1px,
    var(--title-pinstripe) 2px
  );
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  flex-shrink: 0;
  gap: 6px;
}

.window-titlebar:active {
  cursor: grabbing;
}

.titlebar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-face);
  padding: 2px 10px;
  border: 1px solid var(--color-black);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 1px 1px 0 var(--color-white);
  pointer-events: none;
  max-width: calc(100% - 100px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.titlebar-center h1 {
  font-size: inherit;
  font-weight: inherit;
  display: inline;
}

.title-oracle-dot {
  width: 6px;
  height: 6px;
  background: var(--color-black);
  display: inline-block;
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.titlebar-buttons {
  display: flex;
  gap: 3px;
  z-index: 2;
  flex-shrink: 0;
}

.win-btn {
  width: 18px;
  height: 18px;
  background: var(--color-face);
  border-top: 1px solid var(--color-white);
  border-left: 1px solid var(--color-white);
  border-right: 1px solid var(--color-black);
  border-bottom: 1px solid var(--color-black);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-main);
  padding: 0;
  line-height: 1;
  touch-action: manipulation;
}

.win-btn:active {
  border-top: 1px solid var(--color-black);
  border-left: 1px solid var(--color-black);
  border-right: 1px solid var(--color-white);
  border-bottom: 1px solid var(--color-white);
  transform: translate(1px, 1px);
}

/* Window Body */
.window-body {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 6px;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.window-subhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  border-bottom: 1px solid var(--color-shadow);
  padding-bottom: 4px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.subhead-tag {
  border: 1px solid var(--color-black);
  padding: 1px 5px;
  background: var(--color-white);
  color: var(--text-main);
  font-weight: 700;
}

/* 8. Sunken Inset Well & Decree Text */
.sunken-well {
  background: var(--well-bg);
  color: var(--well-text);
  border-top: 2px solid var(--color-shadow);
  border-left: 2px solid var(--color-shadow);
  border-right: 2px solid var(--color-white);
  border-bottom: 2px solid var(--color-white);
  padding: 14px 18px;
  min-height: 80px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  box-shadow: inset 1px 1px 2px rgba(0,0,0,0.3);
  overflow-y: auto;
  overflow-x: hidden;
}

.quote-mark {
  font-family: var(--font-quote);
  font-size: 32px;
  line-height: 0.3;
  color: var(--text-muted);
  user-select: none;
  opacity: 0.5;
  flex-shrink: 0;
}

.quote-mark.top { align-self: flex-start; margin-bottom: 4px; }
.quote-mark.bottom { align-self: flex-end; margin-top: 4px; }

#sentence {
  font-family: var(--font-quote);
  font-size: clamp(1.15rem, 1rem + 1vw, 2.15rem);
  line-height: 1.42;
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.01em;
  max-width: 44ch;
  text-wrap: balance;
  user-select: text;
  -webkit-user-select: text;
  margin: auto 0;
  min-height: 2em;
  display: inline-block;
  position: relative;
}

/* Blinking Block Typewriter Cursor */
.typewriter-cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--color-black);
  vertical-align: -0.12em;
  margin-left: 2px;
  animation: blink-cursor 800ms steps(2, start) infinite;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

#sentence.state-muted {
  font-style: italic;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 1.1rem;
}

/* Hourglass Animation */
.hourglass-loader {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-right: 6px;
  animation: rotate-hourglass 1.5s steps(4) infinite;
}

@keyframes rotate-hourglass {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 9. Skeuomorphic Buttons & Controls */
.controls-deck {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.retro-btn {
  appearance: none;
  touch-action: manipulation;
  background: var(--color-face);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-top: 2px solid var(--color-white);
  border-left: 2px solid var(--color-white);
  border-right: 2px solid var(--color-black);
  border-bottom: 2px solid var(--color-black);
  box-shadow: inset -1px -1px 0px var(--color-shadow);
  outline: none;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.retro-btn:active,
.retro-btn.pressed {
  border-top: 2px solid var(--color-black);
  border-left: 2px solid var(--color-black);
  border-right: 2px solid var(--color-white);
  border-bottom: 2px solid var(--color-white);
  box-shadow: inset 1px 1px 0px var(--color-shadow);
  transform: translate(1px, 1px);
}

.retro-btn:focus-visible {
  outline: 1px dotted var(--color-black);
  outline-offset: -4px;
}

.retro-btn:disabled {
  color: var(--color-shadow);
  cursor: not-allowed;
  border-color: var(--color-shadow);
  box-shadow: none;
  text-shadow: 1px 1px 0 var(--color-white);
}

/* Default Prominent Action with Double Border */
.retro-btn.default-action {
  position: relative;
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 700;
  border: 2px solid var(--color-black);
  box-shadow: 
    0 0 0 1px var(--color-white),
    0 0 0 2px var(--color-black),
    inset 1px 1px 0 var(--color-white),
    inset -1px -1px 0 var(--color-shadow);
}

.retro-btn.default-action:active {
  transform: translate(1px, 1px);
  box-shadow: 
    0 0 0 1px var(--color-white),
    0 0 0 2px var(--color-black),
    inset 1px 1px 0 var(--color-black);
}

/* Cooldown Fill Bar Inside Primary Button */
.btn-cooldown-fill {
  position: absolute;
  left: 0;
  bottom: 0;
  top: 0;
  width: 0%;
  background-color: rgba(0, 0, 0, 0.15);
  background-image: var(--dither-pattern);
  pointer-events: none;
  z-index: 1;
  transition: width 150ms linear;
}

[data-theme="dark"] .btn-cooldown-fill {
  background-color: rgba(255, 255, 255, 0.2);
}

.btn-content-label {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-icon {
  width: 12px;
  height: 12px;
  fill: currentColor;
  display: inline-block;
}

/* 10. Permanent Statusbar */
.window-statusbar {
  display: flex;
  gap: 3px;
  border-top: 1px solid var(--color-shadow);
  padding: 4px 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  align-items: center;
  flex-shrink: 0;
  background: var(--color-face);
}

.status-panel {
  padding: 2px 6px;
  background: var(--color-face);
  border-top: 1px solid var(--color-shadow);
  border-left: 1px solid var(--color-shadow);
  border-right: 1px solid var(--color-white);
  border-bottom: 1px solid var(--color-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-panel.grow { flex: 1; min-width: 60px; }

.status-panel.active-cooldown {
  background: var(--color-black);
  color: var(--color-white);
  font-weight: 700;
}

.window-resize-grip {
  width: 16px;
  height: 16px;
  margin-left: 2px;
  cursor: se-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.window-resize-grip svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--color-black);
  stroke-width: 1.5;
}

.title-text-short { display: none; }

/* 11. Modal Overlays & Zoom-Rect Animation */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(1px);
  padding: 10px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  width: 440px;
  max-width: min(92vw, calc(100vw - 16px));
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  background: var(--color-face);
  border: 2px solid var(--color-black);
  box-shadow: 
    inset 1px 1px 0 var(--color-white),
    inset -1px -1px 0 var(--color-shadow),
    5px 5px 0 rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  position: relative;
  animation: zoom-dialog 140ms ease-out;
}

@keyframes zoom-dialog {
  from {
    transform: scale(0.92);
    opacity: 0.5;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-content {
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.modal-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.modal-text {
  flex: 1;
  font-size: 12px;
  line-height: 1.45;
}

.modal-text h3 {
  font-size: 14px;
  margin-bottom: 6px;
  font-weight: bold;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--color-shadow);
}

/* History List inside Modal */
.history-list {
  max-height: 220px;
  overflow-y: auto;
  background: var(--well-bg);
  border-top: 1px solid var(--color-shadow);
  border-left: 1px solid var(--color-shadow);
  border-right: 1px solid var(--color-white);
  border-bottom: 1px solid var(--color-white);
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  padding: 6px;
  border-bottom: 1px dotted var(--color-shadow);
  user-select: text;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.history-item-text {
  flex: 1;
  line-height: 1.35;
}

.history-item-copy {
  padding: 2px 6px;
  font-size: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Toast */
#toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--color-black);
  color: var(--color-white);
  padding: 6px 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  border: 1px solid var(--color-white);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
  z-index: 2000;
  display: none;
}

/* CRT Scanlines Overlay */
.crt-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.08) 50%);
  background-size: 100% 3px;
  pointer-events: none;
  z-index: 50;
  opacity: 0.6;
}

.crt-overlay.disabled {
  display: none;
}

/* Visually Hidden Helper (for accessible live announcements) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.titlebar-spacer {
  width: 20px;
}

.modal-meta {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}

.modal-box-wide {
  width: 520px;
}

.modal-content-col {
  flex-direction: column;
  gap: 8px;
}

.history-header {
  font-size: 12px;
  font-weight: bold;
}

/* 11b. Petition Window & Chat Transcript */
.os-window-petition {
  position: absolute;
  width: 520px;
  height: 440px;
  min-width: 320px;
  min-height: 280px;
  display: none;
  z-index: 25;
}

.os-window-petition.open {
  display: flex;
}

.transcript-well {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 10px;
  padding: 12px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.45;
  background: var(--well-bg);
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  user-select: text;
  -webkit-user-select: text;
}

.chat-msg-user {
  border-left: 2px solid var(--color-black);
  padding-left: 8px;
  margin-left: 12px;
}

.chat-msg-khariton {
  border-left: 2px solid var(--color-shadow);
  padding-left: 8px;
  background: rgba(0, 0, 0, 0.03);
  padding: 6px 8px;
}

[data-theme="dark"] .chat-msg-khariton {
  background: rgba(255, 255, 255, 0.05);
}

.chat-msg-system {
  font-style: italic;
  color: var(--text-muted);
  text-align: center;
  padding: 6px;
  border: 1px dashed var(--color-shadow);
  font-size: 10.5px;
}

.chat-role {
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.05em;
}

.chat-msg-user .chat-role {
  color: var(--text-muted);
}

.chat-msg-khariton .chat-role {
  color: var(--text-main);
}

.chat-text {
  font-size: 12px;
  word-break: break-word;
}

/* Petition Input Deck */
.petition-input-deck {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.petition-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--well-bg);
  border-top: 2px solid var(--color-shadow);
  border-left: 2px solid var(--color-shadow);
  border-right: 2px solid var(--color-white);
  border-bottom: 2px solid var(--color-white);
  padding: 4px 8px;
}

.retro-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 2px 0;
}

.retro-input::placeholder {
  color: var(--text-muted);
}

.retro-input:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

.char-counter {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  user-select: none;
}

.petition-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.petition-actions-left,
.petition-actions-right {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* 12. Responsive Compaction */
@media (max-width: 768px) {
  #desktop {
    padding: 8px 6px;
  }
  .desktop-icons {
    display: none;
  }
  .os-window {
    width: min(780px, calc(100vw - 12px)) !important;
    max-width: calc(100vw - 12px) !important;
    min-width: 0 !important;
  }
}

@media (max-width: 560px) {
  .status-panel.hide-mobile { display: none; }
  .controls-deck {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
  }
  .controls-left, .controls-right {
    width: 100%;
    display: flex;
    gap: 6px;
  }
  .controls-left #refresh {
    flex: 2;
    min-height: 38px;
    font-size: 12px;
  }
  .controls-left #btn-copy,
  .controls-left #btn-share {
    flex: 1;
    min-height: 38px;
  }
  .controls-right #btn-sound,
  .controls-right #btn-theme {
    flex: 1;
    min-height: 34px;
  }
}

@media (max-width: 440px) {
  .title-text-full { display: none; }
  .title-text-short { display: inline; }
  .titlebar-center {
    font-size: 11px;
    padding: 2px 6px;
    max-width: calc(100% - 70px);
  }
  .subhead-host { display: none; }
  .window-subhead { font-size: 9.5px; }
  .subhead-tag { padding: 1px 4px; font-size: 9px; }
  .sunken-well {
    padding: 10px 10px;
    min-height: 110px;
  }
  #sentence {
    font-size: clamp(1.1rem, 4.3vw, 1.55rem);
    line-height: 1.36;
  }
  .quote-mark {
    font-size: 24px;
  }
  .status-panel {
    font-size: 9.5px;
    padding: 2px 4px;
  }
}

@media (max-width: 360px) {
  .status-panel.hide-xs { display: none; }
  #menubar {
    padding: 0 4px;
    font-size: 11px;
  }
  .menu-item {
    padding: 3px 5px;
  }
  .menu-right {
    font-size: 10px;
  }
  .controls-left #refresh {
    font-size: 11px;
    padding: 4px 6px;
  }
}

/* 13. Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .crt-overlay {
    display: none !important;
  }
  #boot-screen {
    display: none !important;
  }
}
