/* ===== FONTS ===== */
@font-face {
  font-family: 'Trebuchet MS';
  font-style: normal;
  font-weight: 700;
  src: local('Trebuchet MS Bold'), local('TrebuchetMS-Bold');
  font-display: swap;
}

/* ===== CSS VARIABLES ===== */
:root {
  /* Base Colors */
  --bg: #000;
  --text: #fff;
  --surface: rgba(24, 24, 24, 0.8);
  --surface-2: rgba(0, 0, 0, 0.35);
  --muted: #b3b3b3;
  
  /* Brand Colors */
  --primary: #2c5bca;
  --secondary: #a78bfa;
  --accent: #22d3ee;
  --accent-2: #f472b6;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  /* Spacing scale */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Radius scale */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  /* Control sizes */
  --btn-height: 36px;
  /* Exact radius tokens for legacy values */
  --radius-3: 3px;
  --radius-5: 5px;
  --radius-6: 6px;
  --radius-10: 10px;

  /* Interface Colors */
  --input-bg: rgba(13, 13, 13, 1);
  --input-bg-focus: rgba(13, 13, 13, 1);
  --input-border: #1c1c1c;
  --input-border-focus: #262626;
  --button-bg: rgba(21, 21, 21, 0.4);
  --button-bg-hover: rgba(30, 30, 30, 0.6);
  --button-border: #64646429;
  --button-border-hover: #464646;
  --button-shadow: rgba(0, 0, 0, 0.5);
  --border-dark: #242424;
  --border-light: rgba(255, 255, 255, 0.05);
  
  /* Output Background - can be overridden for exports */
  --output-bg: rgba(24, 32, 44, 0.6);
  --output-bg-export: transparent;
  
  /* Scrollbar */
  --scrollbar-thumb: #555;
  --scrollbar-thumb-hover: rgba(255, 255, 255, 1);
  --scrollbar-track: #151515;
  
  /* Chat Colors */
  --me-color: #c2a3da;
  --ame-color: #c2a3da;
  --darkgrey-color: #5a5a5b;
  --grey-color: #939799;
  --lightgrey-color: #c6c4c4;
  --death-color: #f00000;
  --yellow-color: #fbf724;
  --green-color: #56d64b;
  --orange-color: #eda841;
  --blue-color: #3896f3;
  --white-color: #f1f1f1;
  --radio-color: #d6cf8c;
  --radio2-color: #a19558;
  --dep-color: #ccca15;
  --vessel-color: #33c1c9;
  --toyou-color: #ff00bc;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  
  /* Border Radius */
  --border-radius-sm: 0.25rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 1rem;
  
  /* Typography */
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-md: 13px;
  --font-size-lg: 16px;
  
  /* Animation */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-hover: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-hover: 180ms;
  --dur-press: 100ms;
  --dur-panel: 300ms;
  
  /* Elevation */
  --elev-1: 0 6px 16px rgba(0, 0, 0, 0.28);
  --elev-2: 0 12px 32px rgba(0, 0, 0, 0.36);
}

/* ===== BASE STYLES ===== */
*,
::after,
::before {
  box-sizing: border-box;
}

* {
  -webkit-font-smoothing: none !important;
  -moz-osx-font-smoothing: none !important;
}

html {
  height: 100%;
}

html::-webkit-scrollbar {
  width: 0;
  background-color: transparent;
}

body {
  font-family: "Consolas", "Courier New", monospace;
  width: 100%;
  /* Fill the viewport and center the app content */
  height: 100vh;
  height: 100svh;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  background-image: none;
  /* Center the main container in the viewport */
  display: grid;
  place-content: center;
  place-items: center;
  /* Use modern viewport units where available */
  height: 100dvh;
}

/* Avoid accidental horizontal scrolling from fixed tabs or grid min-content sizing */
html, body { overflow-x: hidden; }

/* Inline styles consolidated from index.html */
label { display: none; }
::-webkit-input-placeholder { color: #797979; }
:-ms-input-placeholder { color: #797979; }
::placeholder { color: #797979; }
#chatlogInput::placeholder { color: transparent; }

/* ===== SELECTION ===== */
::-moz-selection {
  background-color: var(--primary);
  color: var(--text);
}

::selection {
  background-color: var(--primary);
  color: var(--text);
}

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* ===== TEXTAREA ===== */
.textarea-container {
  position: relative;
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.textarea-input {
  font-family: "Consolas", "Courier New", monospace;
  -webkit-font-smoothing: none !important;
  width: 100%;
  /* Fixed height with internal scrolling to avoid layout shifts */
  height: 180px;
  padding: var(--space-2);
  margin: 0;
  border: 2px solid var(--input-border);
  border-radius: var(--radius-3);
  background-color: var(--input-bg);
  color: var(--text);
  font-size: var(--font-size-xs);
  letter-spacing: 0.5px;
  resize: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  overflow-y: auto;
}

.textarea-input:focus {
  outline: none;
  border-color: var(--input-border-focus);
  background-color: var(--input-bg-focus);
  box-shadow: none;
}

.textarea-input::placeholder {
  color: #797979;
}

.textarea-input::-webkit-scrollbar {
  width: 10px; /* match global width */
}

.textarea-input::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.textarea-input::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-10);
}

.textarea-input::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* ===== OUTPUT STYLES ===== */
.generated {
  display: inline;
  position: relative;
  padding: 0.1em 0.2em;
  white-space: pre-line;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.3;
  background-color: transparent;
  color: var(--text);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  border-radius: 0;
  background-clip: padding-box;
  margin-bottom: 2px;
  z-index: 1;
}

.background-active {
  background-color: #000;
  padding: var(--space-3);
}

#output {
  position: relative;
  /* Match vertical rhythm with the rest of the UI */
  margin-top: var(--space-6);
  padding: var(--space-5);
  padding-top: var(--space-6);
  padding-bottom: var(--space-4);
  border-radius: var(--radius-md);
  background-color: var(--input-bg);
  box-sizing: border-box;
  overflow: visible;
  font-family: Arial, sans-serif;
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--text);
  letter-spacing: 0.2px;
  line-height: 1.5;
  text-shadow: 0 1px 0 #000, 0 -1px 0 #000, 1px 0 0 #000, -1px 0 0 #000,
    -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  -webkit-font-smoothing: none !important;
  -moz-osx-font-smoothing: none !important;
  text-rendering: optimizeSpeed;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  transition: all var(--dur-panel) var(--ease-spring);
  /* Keep the app from shifting when output grows */
  overflow-y: auto;
  height: min(40vh, 320px);           /* Fixed, responsive height */
  max-height: min(40vh, 320px);       /* Defensive cap */
}

/* Export mode - removes background for clean exports */
#output.export-mode {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  border-radius: var(--space-0) !important;
  box-shadow: none !important;
  border: none !important;
  padding: var(--space-0) !important;
  margin: var(--space-0) !important;
  /* Ensure full content is captured on export */
  max-height: none !important;
  height: auto !important;
  overflow: visible !important;
}

/* Ensure background-active is also overridden in export mode */
#output.export-mode.background-active {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
}

#output.processing {
  opacity: 0.8;
  transform: scale(0.99);
}

/* Output font toggle */
.output-font-trebuchet,
#output.output-font-trebuchet {
  font-family: 'Trebuchet MS', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-weight: 700;
}

/* ===== CHAT COLORS ===== */
.me,
.ame { color: var(--me-color); }
.darkgrey { color: var(--darkgrey-color); }
.grey { color: var(--grey-color); }
.lightgrey { color: var(--lightgrey-color); }
.death { color: var(--death-color); }
.yellow { color: var(--yellow-color); }
.green,
.money { color: var(--green-color); }
.orange,
.whisper { color: var(--orange-color); }
.blue { color: var(--blue-color); }
.white { color: var(--white-color); }
.radioColor { color: var(--radio-color); }
.radioColor2 { color: var(--radio2-color); }
.depColor { color: var(--dep-color); }
.vesseltraffic { color: var(--vessel-color); }
.toyou { color: var(--toyou-color); }

/* ===== BUTTONS ===== */
.button,
button,
input[type="submit"],
input[type="button"] {
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 var(--space-4) !important;
  border: 2px solid var(--button-border) !important;
  border-radius: var(--radius-sm) !important;
  background-color: var(--button-bg) !important;
  color: var(--text) !important;
  font-family: inherit !important;
  font-size: var(--font-size-md) !important;
  font-weight: normal !important;
  line-height: calc(var(--btn-height) - 4px) !important;
  height: var(--btn-height) !important;
  box-sizing: border-box !important;
  text-decoration: none !important;
  text-align: center !important;
  vertical-align: middle !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  /* prevent multi-line labels and keep layout stable */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.button:hover,
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
  border-color: var(--button-border-hover) !important;
  background-color: var(--button-bg-hover) !important;
  box-shadow: 0 2px 8px var(--button-shadow) !important;
  transform: translateY(-1px) !important;
}

.button:active,
button:active,
input[type="submit"]:active,
input[type="button"]:active {
  transform: translateY(0) scale(0.98) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

.button:focus,
button:focus,
input[type="submit"]:focus,
input[type="button"]:focus {
  outline: none !important;
}

/* Button size variants */
/* Normalize size variants to match base sizing */
.button.small,
.button.large {
  padding: var(--space-2) var(--space-4) !important;
  font-size: var(--font-size-md) !important;
  height: var(--btn-height) !important;
}

/* Button accent colors */
#downloadOutputTransparent {
  border-color: var(--success) !important;
  box-shadow: 0 1px 3px rgba(34, 197, 94, 0.2) !important;
  background-color: var(--success) !important;
  color: #000 !important; /* ensure readable contrast on green */
}

#downloadOutputTransparent:hover {
  border-color: #16a34a !important;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4) !important;
  background-color: #22c55e !important; /* keep same tone on hover for stability */
}

#downloadOutputTransparent:focus { outline: none !important; }

#censorCharButton {
  border-color: var(--secondary) !important;
  box-shadow: 0 1px 3px rgba(167, 139, 250, 0.2) !important;
}

#censorCharButton:hover {
  border-color: #8b5cf6 !important;
  box-shadow: 0 2px 8px rgba(167, 139, 250, 0.4) !important;
}

#censorCharButton:focus { outline: none !important; }

.censor-char-button {
  font-weight: bold !important;
}

/* Shared button icon sizing for inline SVGs */
.button .btn-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: middle;
  margin-top: -1px; /* optical alignment tweak */
  pointer-events: none;
}

/* ===== INPUTS & FORMS ===== */
.input-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: 0;
}

.input-group input,
.cell input,
.input-cell input {
  padding: 0 var(--space-2);
  border: 2px solid var(--input-border);
  border-radius: var(--radius-3) !important;
  background-color: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: var(--font-size-md);
  line-height: calc(var(--btn-height) - 4px);
  letter-spacing: 0.5px;
  box-sizing: border-box;
  margin-bottom: 0;
  transition: border-color 0.2s ease;
  height: var(--btn-height);
}

/* Keep number inputs steady when spin buttons appear */
input[type="number"] {
  height: var(--btn-height);
  padding-right: calc(var(--space-1) + 18px);
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { margin: 0; }

.input-group input {
  flex: 1;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.input-group input::placeholder,
.cell input::placeholder,
.input-cell input::placeholder {
  color: #797979;
}

.input-group input:hover,
.cell input:hover,
.input-cell input:hover {
  border-color: var(--input-border-focus);
}

.input-group input:focus,
.cell input:focus,
.input-cell input:focus {
  outline: none;
  border-color: var(--input-border-focus);
  background-color: var(--input-bg-focus);
  box-shadow: none;
}

/* Keyboard-only focus indicator */


.input-group input:-webkit-autofill,
.cell input:-webkit-autofill,
.input-cell input:-webkit-autofill {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 30px rgba(255, 255, 255, 0.08) inset !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* Input group buttons */
.input-group-button .button {
  height: var(--btn-height) !important;
  position: relative;
  overflow: visible !important;
}

.input-group-button .button::before {
  display: none;
}

/* Labels */
label,
.cell label,
.input-cell label {
  display: none;
}

.scale-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.scale-toggle .switch-input {
  appearance: none;
  width: 50px;
  height: 25px;
  background-color: var(--button-bg);
  border-radius: 25px;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background-color 0.3s ease;
}

.scale-toggle .switch-input:checked {
  background-color: #333;
}

.scale-toggle .switch-input::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background-color: var(--text-color);
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.scale-toggle .switch-input:checked::before {
  transform: translateX(25px);
}

.grid-container {
  padding: var(--space-5);
}

.logo-overlay {
  position: absolute;
  top: 0px;
  left: 7px;
  width: 30px;
  height: auto;
  pointer-events: none;
  z-index: 1;
}

.logo-overlay img {
  opacity: 60%;
  max-width: 100%;
  height: auto;
}

.grid-x {
  display: flex;
  flex-wrap: wrap;
}

.pixelated {
  filter: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='pixelate-filter'><feOffset dx='0' dy='0' result='box-blur'/><feFlood x='1' y='1' height='1' width='1'/><feComposite width='3' height='3'/><feTile result='tiles'/><feComposite in='box-blur' operator='in'/><feMorphology operator='dilate' radius='1'/></filter></svg>#pixelate-filter");
}

.hidden {
  opacity: 0;
}

.info-bracket {
  display: inline-block;
  align-items: center;
  justify-content: center;
  padding: 0.7em 1.2em;
  margin: 0 0 var(--space-4) 0;
  border-radius: var(--border-radius-md);
  color: var(--text-color);
  font-size: 0.9rem;
  font-weight: bold;
  border: 1px solid transparent;
  background-color: var(--button-bg);
  cursor: pointer;
  transition: background-color 0.25s ease-out, color 0.25s ease-out, transform 0.3s ease, box-shadow 0.3s ease;
  text-align: center;
  vertical-align: middle;
  line-height: 1;
  position: relative;
}

.info-bracket:hover {
  background-color: var(--button-bg-hover);
  box-shadow: 0 2px 10px var(--button-shadow);
  transform: translateY(-2px);
}

.info-bracket:focus { outline: none; }

.info-icon {
  margin-right: 2px;
}

.tooltip-text {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #444;
  color: var(--text-color);
  padding: var(--space-2);
  border-radius: var(--border-radius-sm);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  z-index: 10;
  white-space: nowrap;
  min-width: 200px;
  text-align: left;
}

.info-bracket:hover .tooltip-text {
  display: block;
}

.censor-char-button {
  font-weight: bold;
}

@media only screen and (max-width: 768px) {
  .grid-container { padding: var(--space-3); }
  .textarea-input { font-size: var(--font-size-md); }
  /* Add breathing room between stacked grid cells */
  .grid-x.align-middle > .cell { margin-bottom: var(--space-2); }
  /* Output spacing handled by stack utilities; keep internal padding a bit tighter on mobile */
  #output { padding: var(--space-4); padding-top: var(--space-5); padding-bottom: var(--space-3); }
  /* Panel tabs: adjust size (no invalid border-radius shorthand) */
  .history-tab { width: 36px; height: 72px; }
  .button { font-size: var(--font-size-md); }
}

/* ===== TOGGLES & SWITCHES ===== */



/* Output font toggle */
.output-font-trebuchet,
#output.output-font-trebuchet {
    font-family: 'Trebuchet MS', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 700;
}

/* Attention animation for Buy Me a Coffee button */
.bmc-btn { display: inline-block; }
.bmc-attn { animation: bmcShake 600ms var(--ease-spring); }
@keyframes bmcShake {
  0% { transform: translateX(0); }
  10% { transform: translateX(-3px); }
  20% { transform: translateX(3px); }
  30% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  50% { transform: translateX(-2px); }
  60% { transform: translateX(2px); }
  70% { transform: translateX(-1px); }
  80% { transform: translateX(1px); }
  100% { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce){
  .bmc-attn { animation: none; }
}





/* ===== OVERLAYS & INDICATORS ===== */
.auto-save-indicator {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  background: rgba(56, 150, 243, 0.9);
  color: var(--text);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-6);
  font-size: 14px;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideInRight 0.3s ease-out;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-dialog {
  background-color: var(--text);
  padding: var(--space-5);
  border-radius: var(--radius-5);
  text-align: center;
}

.loading-dialog .spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 2s linear infinite;
  margin: 0 auto var(--space-3);
}

.loading-dialog .loading-text {
  margin: 0;
  color: #333;
}







/* ===== LAYOUT ===== */
.grid-container {
  padding: var(--space-6);
  background-color: transparent;
  border-radius: 0;
  box-shadow: none;
  /* Keep content comfortably centered and not overly wide */
  width: min(1200px, 100%);
  max-width: 1200px;
  margin: 0 auto;
}

/* If the viewport is short, prefer top alignment to avoid content being cut off */
@media (max-height: 700px) {
  body { align-content: start; }
}

.grid-x {
  display: flex;
  flex-wrap: wrap;
}

.button-group-container {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.input-cell {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* ===== UTILITY CLASSES ===== */
.clear {
  clear: both;
}

.hidden {
  opacity: 0;
}

.pixelated {
  filter: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='pixelate-filter'><feOffset dx='0' dy='0' result='box-blur'/><feFlood x='1' y='1' height='1' width='1'/><feComposite width='3' height='3'/><feTile result='tiles'/><feComposite in='box-blur' operator='in'/><feMorphology operator='dilate' radius='1'/></filter></svg>#pixelate-filter");
}

/* Spacing utilities */
.stack > * + * { margin-top: var(--space-3); }
.stack-sm > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-4); }

/* Force the top inputs row to stack vertically */
#top-inputs {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  width: 100%;
  margin: 0 !important;
  padding: 0 !important;
}

/* Neutralize Foundation grid gutters inside the custom grid to avoid overflow */
#top-inputs.grid-margin-x { margin-left: 0 !important; margin-right: 0 !important; }
#top-inputs > .cell { padding-left: 0 !important; padding-right: 0 !important; }

#top-inputs > .cell {
  width: 100% !important;
  flex: 0 0 100% !important;
  min-width: 0; /* allow grid items to shrink to container width */
  margin: 0 !important;
  padding: 0 !important;
}

/* Make the character input's action buttons sit next to the input but wrap nicely on small screens */
#top-inputs .input-group {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
  position: relative; /* anchor dropdown correctly */
  min-width: 0; /* avoid overflow from min-content sizing */
}

/* Neutralize wrapper styles that make the buttons look like full-width inputs */
#top-inputs .input-group-button {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  width: auto !important;
  box-shadow: none !important;
}

#top-inputs .input-group input { width: 100%; min-width: 0; }

/* Safety: never let controls exceed the container width */
#top-inputs input,
#top-inputs .button {
  max-width: 100%;
}

@media (max-width: 520px) {
  #top-inputs .input-group {
    grid-template-columns: 1fr;
  }
  #top-inputs .input-group-button { display: flex; gap: var(--space-1); }
}

/* On larger phones and up, show first two inputs side-by-side, third spans full width */
@media (min-width: 521px) {
  #top-inputs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--space-3);
    row-gap: var(--space-3);
  }
  /* remove vertical margins from the .stack utility when in grid mode */
  #top-inputs.stack > * + * { margin-top: 0; }
  /* make the third cell (character input) span both columns */
  #top-inputs > .cell:nth-child(3) { grid-column: 1 / -1; }
  /* ensure inputs don’t overflow columns */
  #top-inputs input { min-width: 0; }
}

/* Desktop: place all three controls on one row */
@media (min-width: 768px) {
  #top-inputs {
    grid-template-columns: 140px 140px 1fr;
    column-gap: var(--space-3);
    row-gap: 0;
  }
  #top-inputs.stack > * + * { margin-top: 0; }
  /* third cell no longer spans; stays in column 3 */
  #top-inputs > .cell:nth-child(3) { grid-column: auto; }
  /* character input with buttons on same line */
  #top-inputs .input-group { grid-template-columns: 1fr auto; }
  #top-inputs .input-group-button.inline-gap-sm { display: flex; gap: var(--space-2); }
}

.inline-gap { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.inline-gap-sm { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.inline-gap-lg { display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; }

/* Basic typographic rhythm */
h1, h2, h3, h4, h5, h6 { margin: 0 0 var(--space-3) 0; }
p { margin: 0 0 var(--space-3) 0; }

/* Legacy .logo-overlay removed from textarea to avoid blur */
.logo-overlay,
.logo-overlay img {
  display: none !important;
}

/* ===== COLOR PICKER FEATURES ===== */
.coloring-mode span {
  cursor: pointer;
}

.coloring-mode span:hover {
  outline: 1px dotted rgba(255, 255, 255, 0.5);
}

.selected-for-coloring {
  background-color: rgba(255, 255, 255, 0.2) !important;
  outline: 2px solid var(--blue-color) !important;
}

.colorable {
  display: inline;
}

.coloring-mode .colorable:hover {
  background-color: rgba(255, 255, 255, 0.1);
  outline: 1px dotted var(--blue-color);
}

/* ===== INFO BRACKETS & SPECIAL ELEMENTS ===== */
.info-bracket {
  display: inline-block;
  align-items: center;
  justify-content: center;
  padding: 0.7em 1.2em;
  margin: 0 0 var(--space-4) 0;
  border-radius: var(--border-radius-md);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: bold;
  border: 1px solid transparent;
  background-color: #2d2d2d;
  cursor: pointer;
  transition: all 0.3s var(--ease-hover);
  text-align: center;
  vertical-align: middle;
  line-height: 1;
  position: relative;
  overflow: hidden;
}

.info-bracket::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 165, 0, 0.2), transparent);
  transition: all 0.6s var(--ease-hover);
}

.info-bracket:hover {
  background-color: #3d3d3d;
  box-shadow: 0 4px 15px rgba(255, 165, 0, 0.2);
  transform: translateY(-2px);
}

.info-bracket:hover::before {
  left: 100%;
}

.info-bracket:focus {
  outline: 2px solid rgba(255, 165, 0, 0.3);
  outline-offset: 2px;
}

.info-bracket:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(255, 165, 0, 0.15);
}

.info-icon {
  margin-right: 2px;
}

/* ===== CENSOR CHARACTER DISPLAY ===== */
.censor-char-container {
  display: inline-block;
  vertical-align: middle;
  margin: 0 var(--space-1);
}

.censor-char-display {
  width: 2.5rem;
  height: 2.4rem;
  text-align: center;
  font-size: 1.2rem;
  border: 1px solid #cacaca;
  border-radius: var(--radius-3);
  background-color: #e6e6e6;
  cursor: pointer;
  padding: var(--space-2) 0;
  margin: 0;
  font-weight: bold;
  vertical-align: middle;
  line-height: 1.25;
  display: inline-block;
}

.censor-char-display:hover {
  background-color: #d0d0d0;
}

.censor-char-display:focus {
  outline: none;
}

/* ===== HISTORY & PANELS ===== */
.history-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  background-color: rgba(19, 19, 19, 0.75);
  border: 2px solid #151515;
  border-radius: var(--radius-10);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 100;
  display: none;
}

/* Shared panel styles */
.history-panel {
  position: fixed;
  top: 0;
  width: 350px;
  max-width: 375px;
  min-width: 250px;
  height: 100vh;
  background: var(--surface);
  transition: var(--dur-panel) var(--ease-spring);
  z-index: 1000;
  overflow-x: auto;
  display: flex !important;
  flex-direction: column;
  padding: var(--space-3);
  text-align: center;
}

.history-panel {
  right: -375px;
  border-left: 1px solid rgba(0, 0, 0, 0.15);
  z-index: 1002; /* above .history-tab (1001) so panel overlays the tab */
}

.history-panel.open {
  right: 0;
}

/* Shared header styles */
.history-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(45, 45, 45, 0.95);
  color: var(--text);
  flex-shrink: 0;
}

.history-header h3 {
  margin: 0 var(--space-3) 0 0;
  font-size: 16px;
  font-weight: 500;
}

/* Shared items container styles */
.history-items {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.history-items::-webkit-scrollbar {
  width: 8px;
}

.history-items::-webkit-scrollbar-track {
  background: transparent;
}

.history-items::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-sm);
}

.history-items::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* History specific styles */
.history-item {
  padding: var(--space-1) 0 var(--space-1) var(--space-3);
  cursor: pointer;
  background-color: rgba(0, 0, 0, 0.15);
  transition: background-color 0.1s;
  max-height: 200px;
  overflow-y: auto;
  position: relative;
  border-bottom: 2px solid rgba(255, 255, 255, 0.025);
}

.history-item:hover {
  background-color: rgba(255, 255, 255, 0.085);
}

.history-item:focus { outline: none; }

.history-item-text {
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Apply chat colors to history text */
.history-item-text .me,
.history-item-text .ame { color: var(--me-color); }
.history-item-text .darkgrey { color: var(--darkgrey-color); }
.history-item-text .grey { color: var(--grey-color); }
.history-item-text .lightgrey { color: var(--lightgrey-color); }
.history-item-text .death { color: var(--death-color); }
.history-item-text .yellow { color: var(--yellow-color); }
.history-item-text .green { color: var(--green-color); }
.history-item-text .orange { color: var(--orange-color); }
.history-item-text .blue { color: var(--blue-color); }
.history-item-text .white { color: var(--white-color); }
.history-item-text .radioColor { color: var(--radio-color); }
.history-item-text .radioColor2 { color: var(--radio2-color); }
.history-item-text .depColor { color: var(--dep-color); }
.history-item-text .vesseltraffic { color: var(--vessel-color); }
.history-item-text .toyou { color: var(--toyou-color); }

.history-loading,
.history-empty {
  text-align: center;
  padding: var(--space-5);
  color: #95a5a6;
  display: none;
}

.history-loading.active,
.history-empty.active {
  display: block;
}

.close-btn {
  display: none;
}

.clear-history-btn {
  background: var(--danger);
  color: var(--text);
  border: none;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-3);
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.2s ease;
}

.clear-history-btn:hover {
  background: #c0392b;
}

.clear-history-btn:focus {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ===== PANEL TABS ===== */
.history-tab {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 80px;
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0; /* ensure no stray line box affects centering */
  cursor: pointer;
  z-index: 1001;
  transition: all 0.15s;
  border: 2px solid var(--border-dark);
  opacity: 1;
  pointer-events: auto;
  user-select: none;
}

.history-tab {
  right: 0;
  border-radius: var(--radius-10) 0 0 var(--radius-10);
  border-right: none;
}

.history-tab:hover {
  background: rgba(30, 30, 30, 0.8);
  border-color: #464646;
}

.history-tab:focus { outline: none; }

.history-tab i {
  font-size: 20px;
}

/* Ensure SVG icons in tabs render at the intended size */
.history-tab .tab-icon {
  width: 20px;
  height: 20px;
  display: block;
  margin: 0; /* remove any default spacing */
  pointer-events: none; /* let tab capture the clicks */
}

.history-tab.hidden {
  opacity: 0;
  transform: translateY(-50%) scale(0.8);
  z-index: -1;
}

/* ===== CHARACTER DROPDOWN ===== */
.character-dropdown {
  /* Moved from inline style in index.html */
  display: none;
  position: absolute;
  top: 110%;
  left: 0;
  right: 0;
  background: #222;
  color: #fff;
  border: 1px solid #444;
  z-index: 1000;
  max-height: 150px;
  overflow-y: auto;
  /* Existing visual tweaks */
  background: #2d2d2d !important;
  color: var(--text) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.character-dropdown div {
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.character-dropdown div:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Changelog styles removed */

/* ===== MEDIA QUERIES ===== */
@media (max-width: 768px) {
  .grid-container {
    padding: var(--space-4);
  }

  .textarea-input {
    font-size: var(--font-size-md);
    padding-left: var(--space-2);
    height: 160px; /* slightly shorter on mobile */
  }

    /* Buttons: exactly 2 columns on mobile for clarity */
    .inline-gap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); grid-auto-rows: var(--btn-height); }
    .inline-gap-sm { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-1); grid-auto-rows: var(--btn-height); }
    .inline-gap > .button, .inline-gap-sm > .button { width: 100%; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    /* Input group: ensure wrapping is clean and dropdown anchors properly */
    .input-group { flex-wrap: wrap; position: relative; }
    .input-group input { min-width: 160px; flex: 1 1 100%; }
    .input-group-button { display: flex; gap: var(--space-1); }

  .button {
    font-size: var(--font-size-sm);
    padding: 0 var(--space-3) !important;
  }

  .history-panel {
    width: 300px;
  }

  .history-panel {
    right: -300px;
  }

  .history-tab {
    width: 35px;
    height: 70px;
  }

  .history-tab:hover {
    width: 40px;
  }

  .history-header h3 {
    font-size: 15px;
  }

  /* Top inputs: keep character buttons side-by-side below the input on mobile */
  #top-inputs .input-group { grid-template-columns: 1fr; }
  #top-inputs .input-group-button.inline-gap-sm {
    display: flex;
    gap: var(--space-1);
    flex-wrap: nowrap;
    grid-template-columns: none;
    grid-auto-rows: initial;
  }
  #top-inputs .input-group-button.inline-gap-sm > .button {
    width: auto;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bmc-attn,
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ===== Overrides: unify history styling with app look ===== */
.history-header {
  border-bottom: 1px solid var(--border-dark) !important;
  justify-content: space-between !important;
}

.history-items { text-align: left; }

.history-item {
  padding: var(--space-3) !important;
  background-color: var(--button-bg) !important;
  border: 1px solid var(--border-dark) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--elev-1) !important;
  margin-bottom: var(--space-3) !important;
}
.history-item:hover { background-color: var(--button-bg-hover) !important; border-color: var(--button-border-hover) !important; }

.clear-history-btn {
  padding: 0 var(--space-3) !important;
  height: var(--btn-height) !important;
  line-height: calc(var(--btn-height) - 4px) !important;
  font-size: var(--font-size-sm) !important;
  border-radius: var(--radius-sm) !important;
  background: var(--button-bg) !important;
  color: var(--text) !important;
  border: 2px solid var(--danger) !important;
}
.clear-history-btn:hover { border-color: #dc2626 !important; background: var(--button-bg-hover) !important; }
.clear-history-btn:focus { outline: none !important; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25) !important; }

/* Changelog overrides removed */
#colorPalette {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    display: none;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    min-width: 200px;
}

.color-palette-header {
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    text-align: center;
}

.color-palette-header .selection-counter {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: normal;
    margin-top: 4px;
}

.color-palette-items {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 4px;
}

.color-item {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform var(--dur-hover) var(--ease-hover), box-shadow var(--dur-hover);
    background: currentColor;
    position: relative;
    box-shadow: 0 0 0 0 rgba(255,255,255,0);
}

.color-item::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 10000;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.color-item::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.95);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 10000;
    margin-bottom: 4px;
}

.color-item:hover::before {
    opacity: 1;
    transition-delay: 0.1s;
}

.color-item:hover::after {
    opacity: 1;
    transition-delay: 0.1s;
}

.color-item:hover { transform: scale(1.12); box-shadow: 0 0 16px 0 currentColor, 0 0 2px 1px rgba(255,255,255,0.15); }
.color-item.is-selected { animation: ringPulse 2s var(--ease-spring) infinite; }
@keyframes ringPulse { 0%{ box-shadow:0 0 0 0 currentColor } 70%{ box-shadow:0 0 0 8px rgba(255,255,255,0) } 100%{ box-shadow:0 0 0 0 rgba(255,255,255,0) } }

/* Color classes matching modern.css variables */
.me { color: #c2a3da; }          /* Purple for /me actions */
.ame { color: #c2a3da; }         /* Purple for /ame actions */
.darkgrey { color: #5a5a5b; }    /* Dark grey for [lower] */
.grey { color: #939799; }        /* Grey for [low] */
.lightgrey { color: #c6c4c4; }   /* Light grey for normal text */
.death { color: #f00000; }       /* Bright red for death/failures */
.yellow { color: #fbf724; }      /* Yellow for important info */
.green { color: #56d64b; }       /* Green for success */
.orange { color: #eda841; }      /* Orange for warnings */
.blue { color: #3896f3; }        /* Blue for info */
.white { color: #f1f1f1; }       /* White for normal text */
.radioColor { color: #ffec8b; }  /* Light yellow for radio */
.radioColor2 { color: #a19558; } /* Dark yellow for radio */
.depColor { color: #ccca15; }    /* Yellow-green for department */
.vesseltraffic { color: #33C1C9; } /* Cyan for vessel traffic */
.toyou { color: #ff00bc; }       /* Pink for [!] messages */

.coloring-mode {
    -ms-user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

.coloring-mode .colorable {
    cursor: pointer;
    transition: background-color 0.2s ease;
    -ms-user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

.coloring-mode .colorable:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.selected-for-coloring {
    background-color: rgba(255, 255, 255, 0.25) !important;
    outline: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
    transform: scale(1.02);
    transition: all 0.2s ease;
}

@media print {
    .coloring-mode .colorable:hover,
    .selected-for-coloring {
        background-color: transparent !important;
        outline: none !important;
    }
    
    #colorPalette {
        display: none !important;
    }
}

/* Export context: if a wrapper with .dom-to-image is used, ensure selections are invisible */
.dom-to-image .coloring-mode .colorable:hover,
.dom-to-image .selected-for-coloring {
    background-color: transparent !important;
    outline: none !important;
}

.dom-to-image #colorPalette {
    display: none !important;
}

.color-applied-feedback {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: rgba(56, 150, 243, 0.9);
	color: white;
	padding: 8px 16px;
	border-radius: 6px;
	font-size: 14px;
	z-index: 10001;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
	animation: fadeInOut 1s ease-in-out;
}

@keyframes fadeInOut {
	0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
	20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
	80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
	100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

@media (max-width: 768px) {
    #colorPalette {
        right: 10px;
        bottom: 10px;
        padding: 8px;
        min-width: 180px;
    }

    .color-item {
        width: 32px;
        height: 32px;
    }

    .color-palette-header {
        font-size: 13px;
        margin-bottom: 8px;
    }
}

#colorPalette {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    display: none;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    min-width: 200px;
}

.color-palette-header {
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    text-align: center;
}

.color-palette-header .selection-counter {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: normal;
    margin-top: 4px;
}

.color-palette-items {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 4px;
}

.color-item {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform var(--dur-hover) var(--ease-hover), box-shadow var(--dur-hover);
    background: currentColor;
    position: relative;
    box-shadow: 0 0 0 0 rgba(255,255,255,0);
}

.color-item::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 10000;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.color-item::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.95);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 10000;
    margin-bottom: 4px;
}

.color-item:hover::before {
    opacity: 1;
    transition-delay: 0.1s;
}

.color-item:hover::after {
    opacity: 1;
    transition-delay: 0.1s;
}

.color-item:hover { transform: scale(1.12); box-shadow: 0 0 16px 0 currentColor, 0 0 2px 1px rgba(255,255,255,0.15); }
.color-item.is-selected { animation: ringPulse 2s var(--ease-spring) infinite; }
@keyframes ringPulse { 0%{ box-shadow:0 0 0 0 currentColor } 70%{ box-shadow:0 0 0 8px rgba(255,255,255,0) } 100%{ box-shadow:0 0 0 0 rgba(255,255,255,0) } }

/* Color classes matching modern.css variables */
.me { color: #c2a3da; }          /* Purple for /me actions */
.ame { color: #c2a3da; }         /* Purple for /ame actions */
.darkgrey { color: #5a5a5b; }    /* Dark grey for [lower] */
.grey { color: #939799; }        /* Grey for [low] */
.lightgrey { color: #c6c4c4; }   /* Light grey for normal text */
.death { color: #f00000; }       /* Bright red for death/failures */
.yellow { color: #fbf724; }      /* Yellow for important info */
.green { color: #56d64b; }       /* Green for success */
.orange { color: #eda841; }      /* Orange for warnings */
.blue { color: #3896f3; }        /* Blue for info */
.white { color: #f1f1f1; }       /* White for normal text */
.radioColor { color: #ffec8b; }  /* Light yellow for radio */
.radioColor2 { color: #a19558; } /* Dark yellow for radio */
.depColor { color: #ccca15; }    /* Yellow-green for department */
.vesseltraffic { color: #33C1C9; } /* Cyan for vessel traffic */
.toyou { color: #ff00bc; }       /* Pink for [!] messages */

.coloring-mode {
    -ms-user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

.coloring-mode .colorable {
    cursor: pointer;
    transition: background-color 0.2s ease;
    -ms-user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

.coloring-mode .colorable:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.selected-for-coloring {
    background-color: rgba(255, 255, 255, 0.25) !important;
    outline: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
    transform: scale(1.02);
    transition: all 0.2s ease;
}

@media print {
    .coloring-mode .colorable:hover,
    .selected-for-coloring {
        background-color: transparent !important;
        outline: none !important;
    }
    
    #colorPalette {
        display: none !important;
    }
}

/* Export context: if a wrapper with .dom-to-image is used, ensure selections are invisible */
.dom-to-image .coloring-mode .colorable:hover,
.dom-to-image .selected-for-coloring {
    background-color: transparent !important;
    outline: none !important;
}

.dom-to-image #colorPalette {
    display: none !important;
}

.color-applied-feedback {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: rgba(56, 150, 243, 0.9);
	color: white;
	padding: 8px 16px;
	border-radius: 6px;
	font-size: 14px;
	z-index: 10001;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
	animation: fadeInOut 1s ease-in-out;
}

@keyframes fadeInOut {
	0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
	20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
	80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
	100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

@media (max-width: 768px) {
    #colorPalette {
        right: 10px;
        bottom: 10px;
        padding: 8px;
        min-width: 180px;
    }

    .color-item {
        width: 32px;
        height: 32px;
    }

    .color-palette-header {
        font-size: 13px;
        margin-bottom: 8px;
    }
}