/* ============================================================
   Theme Studio.exe — Styles
   All colors via CSS variables so this app re-themes with the OS.
   No hardcoded color literals (except as fallbacks).
   ============================================================ */

.theme-studio {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: var(--c-content-bg, #fff);
  color: var(--c-content-text, #000);
  font-family: var(--font-system, 'Galmuri11', 'Dotum', monospace);
  font-size: var(--fs-base, 11px);
  overflow: hidden;
}

/* ─── Toolbar ─────────────────────────────────────────── */

.ts-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--c-bg, #c0c0c0);
  border-bottom: 1px solid var(--c-black, #000);
}

.ts-toolbar-search { flex: 1; }

.ts-toolbar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-base, 11px);
  cursor: default;
  user-select: none;
  white-space: nowrap;
  padding: 2px 4px;
}

.ts-toolbar-toggle input { margin: 0 4px 0 0; }

/* ─── Body (sidebar + main) ───────────────────────────── */

.ts-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar */

.ts-sidebar {
  flex: 0 0 168px;
  background: var(--c-bg, #c0c0c0);
  border-right: 1px solid var(--c-black, #000);
  border-top: 1px solid var(--c-white, #fff);
  overflow-y: auto;
  padding: 4px 0;
}

.ts-group-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ts-group-list li {
  margin: 0;
  padding: 0 4px;
}

.ts-sidebar-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--c-bg-dark, #808080);
  border-top: 0;
  padding: 0;
  pointer-events: none;
}

.ts-group-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 4px 6px;
  margin: 1px 0;
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: default;
  user-select: none;
}

.ts-group-btn:hover {
  background: var(--c-bg-light, #dfdfdf);
}

.ts-group-btn.is-active {
  background: var(--c-title-active-from, #000080);
  color: var(--c-title-text, #fff);
  border-top: 1px solid var(--c-black, #000);
  border-left: 1px solid var(--c-black, #000);
  border-right: 1px solid var(--c-white, #fff);
  border-bottom: 1px solid var(--c-white, #fff);
}

.ts-group-icon {
  flex: 0 0 auto;
  font-size: 13px;
  width: 16px;
  text-align: center;
}

.ts-group-label {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ts-group-count {
  flex: 0 0 auto;
  font-size: 9px;
  opacity: 0.7;
  padding: 0 4px;
  background: var(--c-bg-dark, #808080);
  color: var(--c-white, #fff);
  border-radius: 0;
  min-width: 18px;
  text-align: center;
}

.ts-group-btn.is-active .ts-group-count {
  background: var(--c-white, #fff);
  color: var(--c-black, #000);
}

/* Main panel */

.ts-main {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 16px 16px;
  background: var(--c-content-bg, #fff);
  min-width: 0;
}

.ts-main-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--c-bg-dark, #808080);
}

.ts-main-header h2 {
  margin: 0;
  font-size: 14px;
  font-family: var(--font-system, 'Galmuri11Bold', monospace);
  font-weight: normal;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ts-main-count {
  font-size: 10px;
  opacity: 0.6;
}

.ts-section-hint {
  margin: 0 0 12px;
  font-size: 10px;
  opacity: 0.7;
  line-height: 1.5;
}

.ts-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 11px;
  color: var(--c-disabled, #808080);
  line-height: 1.7;
}

/* ─── Token rows ──────────────────────────────────────── */

.ts-token-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ts-token-row {
  padding: 6px 8px;
  border: 1px solid transparent;
}

.ts-token-row:hover {
  background: var(--c-bg-light, #dfdfdf);
}

.ts-token-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ts-token-label {
  flex: 1 1 50%;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: default;
  user-select: none;
  min-width: 0;
}

.ts-token-icon {
  flex: 0 0 auto;
  width: 16px;
  text-align: center;
  font-size: 13px;
}

.ts-token-label > span:nth-child(2) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ts-token-badge {
  font-size: 8px;
  background: var(--c-bg-dark, #808080);
  color: var(--c-white, #fff);
  padding: 1px 4px;
  letter-spacing: 0.5px;
}

.ts-token-control {
  flex: 1 1 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ts-token-desc {
  margin: 4px 0 0 22px;
  font-size: 9px;
  opacity: 0.55;
  line-height: 1.4;
}

/* ─── Inputs (Win98 bevel) ────────────────────────────── */

.ts-input,
.ts-text,
.ts-select,
.ts-color-text,
.ts-name-input {
  font-family: var(--font-system, 'Galmuri11', 'Dotum', monospace);
  font-size: var(--fs-base, 11px);
  color: var(--c-content-text, #000);
  background: var(--c-white, #fff);
  border-top: 1px solid var(--c-bg-darker, #404040);
  border-left: 1px solid var(--c-bg-darker, #404040);
  border-right: 1px solid var(--c-white, #fff);
  border-bottom: 1px solid var(--c-white, #fff);
  box-shadow: inset 1px 1px 0 var(--c-bg-dark, #808080);
  padding: 2px 4px;
  outline: none;
  min-width: 0;
  box-sizing: border-box;
}

.ts-search { width: 100%; }
.ts-text   { width: 100%; }
.ts-select { width: 100%; cursor: default; }
.ts-color-text {
  width: 80px;
  font-family: var(--font-mono, 'Galmuri11', monospace);
}
.ts-name-input { width: 180px; }

.ts-input:focus,
.ts-text:focus,
.ts-select:focus,
.ts-color-text:focus,
.ts-name-input:focus {
  outline: 1px dotted var(--c-content-text, #000);
  outline-offset: -3px;
}

/* Slider */

.ts-slider {
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--c-bg-dark, #808080);
  border-top: 1px solid var(--c-bg-darker, #404040);
  border-left: 1px solid var(--c-bg-darker, #404040);
  border-right: 1px solid var(--c-white, #fff);
  border-bottom: 1px solid var(--c-white, #fff);
  min-width: 0;
}
.ts-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 18px;
  background: var(--c-bg, #c0c0c0);
  border-top: 1px solid var(--c-white, #fff);
  border-left: 1px solid var(--c-white, #fff);
  border-right: 1px solid var(--c-black, #000);
  border-bottom: 1px solid var(--c-black, #000);
  box-shadow: inset 1px 1px 0 var(--c-bg-light, #dfdfdf), inset -1px -1px 0 var(--c-bg-dark, #808080);
  cursor: default;
}
.ts-slider::-moz-range-thumb {
  width: 10px;
  height: 16px;
  background: var(--c-bg, #c0c0c0);
  border: 1px solid var(--c-black, #000);
  border-radius: 0;
}

.ts-slider-out {
  flex: 0 0 auto;
  min-width: 52px;
  text-align: right;
  font-family: var(--font-mono, 'Galmuri11', monospace);
  font-size: 10px;
  color: var(--c-content-text, #000);
}

/* Color */

.ts-color {
  flex: 0 0 auto;
  width: 32px;
  height: 22px;
  padding: 0;
  background: var(--c-bg, #c0c0c0);
  border-top: 1px solid var(--c-bg-darker, #404040);
  border-left: 1px solid var(--c-bg-darker, #404040);
  border-right: 1px solid var(--c-white, #fff);
  border-bottom: 1px solid var(--c-white, #fff);
  box-shadow: inset 1px 1px 0 var(--c-bg-dark, #808080);
  cursor: default;
}
.ts-color::-webkit-color-swatch-wrapper { padding: 1px; }
.ts-color::-webkit-color-swatch { border: 1px solid var(--c-black, #000); }

/* Toggle */

.ts-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: default;
  user-select: none;
}
.ts-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.ts-toggle-track {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 14px;
  background: var(--c-bg-dark, #808080);
  border-top: 1px solid var(--c-bg-darker, #404040);
  border-left: 1px solid var(--c-bg-darker, #404040);
  border-right: 1px solid var(--c-white, #fff);
  border-bottom: 1px solid var(--c-white, #fff);
}
.ts-toggle-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 10px;
  background: var(--c-bg, #c0c0c0);
  border-top: 1px solid var(--c-white, #fff);
  border-left: 1px solid var(--c-white, #fff);
  border-right: 1px solid var(--c-black, #000);
  border-bottom: 1px solid var(--c-black, #000);
  transition: left 0.08s ease;
}
.ts-toggle-input:checked + .ts-toggle-track {
  background: var(--c-title-active-from, #000080);
}
.ts-toggle-input:checked + .ts-toggle-track .ts-toggle-thumb {
  left: 15px;
}
.ts-toggle-state {
  font-family: var(--font-mono, 'Galmuri11', monospace);
  font-size: 9px;
  min-width: 22px;
  color: var(--c-content-text, #000);
}

/* ─── Presets grid ────────────────────────────────────── */

.ts-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin: 4px 0;
}

.ts-preset-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 8px;
  background: var(--c-bg, #c0c0c0);
  color: var(--c-content-text, #000);
  border-top: 1px solid var(--c-white, #fff);
  border-left: 1px solid var(--c-white, #fff);
  border-right: 1px solid var(--c-black, #000);
  border-bottom: 1px solid var(--c-black, #000);
  font: inherit;
  text-align: left;
  cursor: default;
  user-select: none;
}

.ts-preset-card:hover {
  background: var(--c-bg-light, #dfdfdf);
}

.ts-preset-card:active {
  border-top: 1px solid var(--c-black, #000);
  border-left: 1px solid var(--c-black, #000);
  border-right: 1px solid var(--c-white, #fff);
  border-bottom: 1px solid var(--c-white, #fff);
}

.ts-preset-swatch {
  height: 48px;
  background: linear-gradient(135deg,
    var(--c-title-active-from, #000080),
    var(--c-title-active-to, #1084d0));
  border: 1px solid var(--c-black, #000);
}

.ts-preset-name {
  font-family: var(--font-system, 'Galmuri11Bold', monospace);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ts-preset-persona {
  font-size: 9px;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ts-preset-tags {
  font-size: 9px;
  opacity: 0.7;
  font-family: var(--font-mono, 'Galmuri11', monospace);
}

/* ─── My Themes grid ──────────────────────────────────── */

.ts-mytheme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.ts-mytheme-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: var(--c-bg, #c0c0c0);
  border-top: 1px solid var(--c-white, #fff);
  border-left: 1px solid var(--c-white, #fff);
  border-right: 1px solid var(--c-black, #000);
  border-bottom: 1px solid var(--c-black, #000);
}

.ts-mytheme-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.ts-mytheme-name {
  font-family: var(--font-system, 'Galmuri11Bold', monospace);
  font-size: 11px;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ts-mytheme-del {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  background: var(--c-bg, #c0c0c0);
  color: var(--c-content-text, #000);
  border-top: 1px solid var(--c-white, #fff);
  border-left: 1px solid var(--c-white, #fff);
  border-right: 1px solid var(--c-black, #000);
  border-bottom: 1px solid var(--c-black, #000);
  cursor: default;
  padding: 0;
}
.ts-mytheme-del:active {
  border-top: 1px solid var(--c-black, #000);
  border-left: 1px solid var(--c-black, #000);
  border-right: 1px solid var(--c-white, #fff);
  border-bottom: 1px solid var(--c-white, #fff);
}

.ts-mytheme-tags { font-size: 9px; opacity: 0.7; font-family: var(--font-mono, 'Galmuri11', monospace); }
.ts-mytheme-date { font-size: 9px; opacity: 0.5; }

.ts-mytheme-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

/* ─── Footer ──────────────────────────────────────────── */

.ts-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--c-bg, #c0c0c0);
  border-top: 1px solid var(--c-white, #fff);
  border-top-color: var(--c-white, #fff);
}

.ts-footer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}

/* Win98 button */

.ts-btn {
  font-family: var(--font-system, 'Galmuri11', 'Dotum', monospace);
  font-size: var(--fs-base, 11px);
  color: var(--c-content-text, #000);
  background: var(--c-bg, #c0c0c0);
  padding: 3px 10px;
  min-width: 64px;
  border-top: 1px solid var(--c-white, #fff);
  border-left: 1px solid var(--c-white, #fff);
  border-right: 1px solid var(--c-black, #000);
  border-bottom: 1px solid var(--c-black, #000);
  box-shadow:
    inset 1px 1px 0 var(--c-bg-light, #dfdfdf),
    inset -1px -1px 0 var(--c-bg-dark, #808080);
  cursor: default;
  user-select: none;
  white-space: nowrap;
}

.ts-btn:hover { background: var(--c-bg-light, #dfdfdf); }

.ts-btn:active,
.ts-btn.is-active {
  border-top: 1px solid var(--c-black, #000);
  border-left: 1px solid var(--c-black, #000);
  border-right: 1px solid var(--c-white, #fff);
  border-bottom: 1px solid var(--c-white, #fff);
  box-shadow:
    inset 1px 1px 0 var(--c-bg-dark, #808080),
    inset -1px -1px 0 var(--c-bg-light, #dfdfdf);
}

.ts-btn:focus {
  outline: 1px dotted var(--c-content-text, #000);
  outline-offset: -4px;
}

.ts-btn-primary {
  font-family: var(--font-system, 'Galmuri11Bold', monospace);
}

.ts-btn-warn { color: var(--c-error, #c00); }

/* Small button inside cards */
.ts-mytheme-actions .ts-btn { padding: 2px 6px; min-width: 0; font-size: 10px; }

/* ─── Fatal error state ───────────────────────────────── */

.ts-fatal {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
  text-align: center;
  background: var(--c-content-bg, #fff);
  color: var(--c-content-text, #000);
  font-family: var(--font-system, 'Galmuri11', 'Dotum', monospace);
}
.ts-fatal-icon { font-size: 36px; margin-bottom: 8px; }
.ts-fatal h2 { font-size: 13px; margin: 4px 0; font-weight: normal; }
.ts-fatal p { font-size: 10px; line-height: 1.6; }
.ts-fatal code {
  background: var(--c-bg, #c0c0c0);
  padding: 1px 4px;
  font-family: var(--font-mono, 'Galmuri11', monospace);
}

/* ─── Responsive (narrow window) ──────────────────────── */

@media (max-width: 640px) {
  .ts-sidebar { flex-basis: 110px; }
  .ts-token-head { flex-direction: column; align-items: stretch; gap: 4px; }
  .ts-token-label, .ts-token-control { flex-basis: auto; }
  .ts-footer { flex-wrap: wrap; }
  .ts-name-input { width: 100%; }
  .ts-footer-actions { margin-left: 0; width: 100%; }
}
