:root {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --input-bg: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --input-bg: #0f172a;
  }
}

/* Thin Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
  gap: 24px;
  max-width: 100%;
  margin: 0;
  padding: 24px 16px 58px 16px;
  box-sizing: border-box;
  flex: 1;
  align-items: stretch;
}

.left-section,
.middle-section,
.right-section,
.cost-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  box-sizing: border-box;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 82px);
  max-height: calc(100vh - 82px);
  overflow-y: auto;
}

h2 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 20px;
  margin-bottom: 10px;
}

label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 10px;
  cursor: pointer;
}

input[type="text"] {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  font-family: 'Fira Code', monospace;
  box-sizing: border-box;
  margin-top: 4px;
  outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--primary);
}

select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 2px 6px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.cost-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 8px;
}

.cost-col {
  display: flex;
  flex-direction: column;
}

.cost-col label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.adjustment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text);
}

.btn-adjust-group {
  display: flex;
  gap: 2px;
}

input[type="number"] {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 2px 4px;
  font-size: 12px;
  font-family: inherit;
  width: 46px;
  text-align: right;
  outline: none;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

button {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: background-color 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-adjust {
  padding: 2px 6px;
  font-size: 12px;
  min-width: 22px;
  height: 22px;
  line-height: 1;
  margin-left: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-adjust:hover:not(:disabled) {
  background: var(--border);
}

.btn-zero {
  padding: 4px 10px;
  font-size: 11px;
  margin-top: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-zero:hover:not(:disabled) {
  background: var(--border);
}

.breakdown-table, .stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 13px;
}

.breakdown-table th, .stats-table th {
  text-align: left;
  padding: 8px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.breakdown-table td, .stats-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.cubecapo-partition-boundary td {
  border-top: 2px dashed var(--border);
}

.stats-table td {
  text-align: right;
  font-weight: 500;
}

details {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  margin: 12px 0;
  padding: 10px;
}

summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

#advancedContent {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.config-tabs {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.tab-buttons,
.main-tab-buttons {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  overflow-x: auto;
}

.tab-buttons button,
.main-tab-btn {
  flex: 1;
  text-align: center;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-muted);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab-buttons button:hover,
.tab-buttons button:hover:not(:disabled),
.main-tab-btn:hover,
.main-tab-btn:hover:not(:disabled) {
  color: var(--text);
  background: transparent;
}

.tab-buttons button.active,
.main-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
}

.main-tab-content {
  display: none;
  flex-direction: column;
  flex: 1;
}

.main-tab-content.active {
  display: flex;
}

.strategy-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1;
}

.strategy-group {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
}

.strategy-group h3 {
  margin: 0 0 10px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.strategy-fields {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.strategy-fields label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
  cursor: pointer;
}

.strategy-fields label:last-child {
  margin-bottom: 0;
}

.cost-tab-content {
  display: none;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1;
}

.cost-tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cost-subtab-buttons {
  margin-bottom: 10px;
}

.cost-form input[type="number"] {
  color: #0f172a;
  font-weight: 600;
}

.group-separator {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.scramble-container {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scramble-meta {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0px;
  margin-bottom: 6px;
  text-align: center;
}

.scramble-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.scramble-page-indicator {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.pagination-btn {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  user-select: none;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--border);
  color: var(--primary);
}

.pagination-btn:disabled {
  opacity: 0.35;
  cursor: auto;
}

#output {
  font-family: 'Fira Code', monospace;
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  word-break: break-word;
  color: var(--primary);
}

#errorMessage {
  font-size: 13px;
  font-weight: 500;
  margin-top: 6px;
  color: #dc2626;
}

.footer-fixed {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 8px;
  font-size: 12px;
  z-index: 1000;
}

.footer-fixed a {
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.footer-fixed a:hover {
  color: var(--text);
}


#submitButton {
  width: 100%;
  margin-top: 12px;
}

#myChart {
  width: 100%;
  max-width: 100%;
  height: 240px;
  min-height: 220px;
  flex-shrink: 0;
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  box-sizing: border-box;
}

.chart-empty {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
}

.chart-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
}

.chart-bars-container {
  display: flex;
  align-items: flex-end;
  height: 100%;
  padding-bottom: 22px;
  padding-left: 12px;
  padding-right: 12px;
  position: relative;
  box-sizing: border-box;
  overflow: hidden;
}

.chart-col {
  flex: 1 1 0px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
  border-right: 1px solid var(--bg);
}

.chart-col:last-child {
  border-right: none;
}

.chart-bar {
  width: 100%;
  min-height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  transition: opacity 0.15s ease;
}

.chart-bar:hover {
  opacity: 0.8;
  outline: 1px solid var(--accent, var(--primary));
  z-index: 2;
}

.chart-label {
  position: absolute;
  bottom: -20px;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  transform: translateX(-50%);
  left: 50%;
  pointer-events: none;
}

.chart-label.chart-label-first {
  transform: translateX(0);
  left: 0;
}

.chart-label.chart-label-last {
  transform: translateX(-100%);
  left: 100%;
}

.profile-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 10px 0;
  line-height: 1.4;
}

.profile-actions {
  display: flex;
  gap: 8px;
}

.btn-profile {
  flex: 1;
  text-align: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-profile:hover:not(:disabled) {
  background: var(--border);
}

.btn-profile.btn-danger {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-profile.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
}

.hidden {
  display: none !important;
}

.footer-fixed img {
  width: 16px;
  vertical-align: middle;
  margin-right: 4px;
}

.unsaved-changes-bar {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 2000;
  transition: bottom 0.2s ease, opacity 0.2s ease;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.unsaved-changes-bar.hidden {
  bottom: -80px;
  opacity: 0;
  pointer-events: none;
}

.bar-buttons {
  display: flex;
  gap: 6px;
}

.btn-revert {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}

.btn-revert:hover {
  background: var(--border) !important;
}

.btn-save {
  background: var(--primary) !important;
  color: #ffffff !important;
}

/* Transitions Tab Styles */
.subtab-buttons {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: var(--bg);
  padding: 3px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.subtab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.subtab-btn:hover,
.subtab-btn:hover:not(:disabled) {
  color: var(--text);
  background: transparent;
}

.subtab-btn.active,
.subtab-btn.active:hover,
.subtab-btn.active:hover:not(:disabled) {
  background: var(--card-bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.transition-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.transition-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.transition-header-row {
  display: grid;
  grid-template-columns: 32px 1fr 28px 1fr 32px;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.transition-header-row span:first-child,
.transition-header-row span:last-child {
  text-align: left;
}

.transition-header-row span:last-child,
.transition-row .transition-move-label:last-child {
  padding-left: 8px;
}

.transition-row {
  display: grid;
  grid-template-columns: 32px 1fr 28px 1fr 32px;
  gap: 8px;
  align-items: center;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.1s ease;
}

.transition-row:hover {
  background: var(--bg);
}

.transition-move-label {
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  color: var(--text);
}

.transition-row select {
  width: 100%;
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 4px;
}

.select-mirrored {
  opacity: 0.85;
  border-style: dashed;
}

.icon-svg {
  display: inline-block;
  width: 1em;
  height: 1em;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  vertical-align: middle;
}

.icon-link {
  -webkit-mask-image: url("./assets/link.svg");
  mask-image: url("./assets/link.svg");
}

.icon-unlink {
  -webkit-mask-image: url("./assets/unlink.svg");
  mask-image: url("./assets/unlink.svg");
}

.icon-github {
  -webkit-mask-image: url("./assets/github.svg");
  mask-image: url("./assets/github.svg");
}

.btn-link-toggle {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.btn-link-toggle:hover,
.btn-link-toggle:hover:not(:disabled) {
  background: var(--border);
}

.btn-link-toggle.linked {
  color: var(--primary);
  opacity: 0.95;
}

.btn-link-toggle.unlinked {
  color: var(--text-muted);
  opacity: 0.4;
}

.btn-link-toggle .icon-svg {
  width: 1em;
  height: 1em;
}