:root {
  --bg: #f2f2f4;
  --bg-2: #e8e8ec;
  --panel: rgba(255, 255, 255, 0.96);
  --surface: rgba(255, 255, 255, 0.92);
  --surface-soft: rgba(249, 249, 251, 0.98);
  --border: rgba(20, 20, 20, 0.05);
  --text: #161416;
  --muted: #77747b;
  --muted-2: #5d5962;
  --shadow-card: 0 13px 28px rgba(0, 0, 0, 0.15);
  --shadow-soft: 0 6px 13px rgba(0, 0, 0, 0.08);
  --shadow-tab: 0 6px 13px rgba(0, 0, 0, 0.17);
  --status-bg: rgba(255, 255, 255, 0.92);
  --status-idle: #161416;
  --status-loading: #161416;
  --status-success: #161416;
  --status-error: #161416;
  --overlay: rgba(18, 18, 20, 0.74);
  --viewer-shade: 239;
  --viewer-bg: linear-gradient(
    180deg,
    rgb(var(--viewer-shade), var(--viewer-shade), var(--viewer-shade)) 0%,
    rgb(calc(var(--viewer-shade) - 10), calc(var(--viewer-shade) - 10), calc(var(--viewer-shade) - 10)) 100%
  );
  --toggle-bg: rgba(0, 0, 0, 0.1);
  --toggle-thumb: #ffffff;
  --toggle-border: rgba(20, 20, 20, 0.06);
  --primary-bg: #19171a;
  --primary-text: #ffffff;
  --secondary-bg: rgba(255, 255, 255, 0.78);
  --secondary-text: #161416;
  --tab-token: #16a9d7;
  --tab-token-text: #ffffff;
  --tab-text: #16a34a;
  --tab-text-text: #ffffff;
  --tab-image: #a3c81d;
  --tab-image-text: #101010;
  --tab-four: #f2df1b;
  --tab-four-text: #101010;
  --tab-model: #f39a1b;
  --tab-model-text: #101010;
  --tab-info: #8b7cf6;
  --tab-info-text: #ffffff;
}

body[data-theme="dark"] {
  --bg: #000000;
  --bg-2: #000000;
  --panel: rgba(20, 20, 20, 0.98);
  --surface: rgba(34, 34, 34, 0.96);
  --surface-soft: rgba(28, 28, 28, 1);
  --border: rgba(255, 255, 255, 0.06);
  --text: #f4f4f7;
  --muted: #b2b1b8;
  --muted-2: #d5d4da;
  --shadow-card: 0 15px 32px rgba(0, 0, 0, 0.54);
  --shadow-soft: 0 7px 15px rgba(0, 0, 0, 0.3);
  --shadow-tab: 0 6px 13px rgba(0, 0, 0, 0.42);
  --status-bg: rgba(35, 35, 40, 0.95);
  --status-idle: #ffffff;
  --status-loading: #ffffff;
  --status-success: #ffffff;
  --status-error: #ffffff;
  --overlay: rgba(5, 5, 8, 0.8);
  --toggle-bg: rgba(255, 255, 255, 0.12);
  --toggle-thumb: #ffffff;
  --toggle-border: rgba(255, 255, 255, 0.08);
  --primary-bg: #ffffff;
  --primary-text: #131316;
  --secondary-bg: rgba(48, 48, 54, 0.95);
  --secondary-text: #f4f4f7;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Roboto", Arial, sans-serif;
  font-weight: 300;
  color: var(--text);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
  padding: 2px 16px 16px;
}

.site-header {
  max-width: 1080px;
  margin: 0 auto 2px;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 26px;
  min-width: 0;
}

.brand-logo {
  width: auto;
  height: 72px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-family: "Roboto", Arial, sans-serif;
  font-size: clamp(34px, 4vw, 46px);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 300;
  text-align: left;
  white-space: nowrap;
}

.header-center {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

.header-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}

.global-status {
  min-height: 44px;
  min-width: 240px;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 11px;
  background: var(--status-bg);
  box-shadow: var(--shadow-soft);
  color: var(--status-idle);
  font-size: 16px;
  line-height: 1.4;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}

.global-status.loading {
  color: var(--status-loading);
}

.global-status.success {
  color: var(--status-success);
}

.global-status.error {
  color: var(--status-error);
}

.theme-toggle {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.theme-toggle-track {
  position: relative;
  width: 60px;
  height: 34px;
  border-radius: 999px;
  background: var(--toggle-bg);
  border: 1px solid var(--toggle-border);
  box-shadow: var(--shadow-soft);
  display: block;
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--toggle-thumb);
  box-shadow: var(--shadow-soft);
  transition: left 0.2s ease;
}

body[data-theme="dark"] .theme-toggle-thumb {
  left: 31px;
}

.workspace {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
}

.tab-rail {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  padding-top: 15px;
  padding-bottom: 15px;
}

.tab-info {
  margin-top: auto;
}

.side-tab {
  width: 64px;
  min-height: 64px;
  border: none;
  border-radius: 18px 0 0 18px;
  box-shadow: var(--shadow-tab);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 5px;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease, width 0.18s ease, min-height 0.18s ease;
}

.side-tab span {
  writing-mode: vertical-rl;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: 0.03em;
  font-weight: 500;
}

.side-tab:hover {
  transform: translateX(-2px);
}

.side-tab.active {
  width: 88px;
  min-height: 74px;
  transform: translateX(0);
  filter: saturate(1.04) brightness(1.02);
  box-shadow: none;
  position: relative;
  z-index: 3;
}

#tab-btn-token {
  background: var(--tab-token);
  color: var(--tab-token-text);
}

#tab-btn-text {
  background: var(--tab-text);
  color: var(--tab-text-text);
}

#tab-btn-image {
  background: var(--tab-image);
  color: var(--tab-image-text);
}

#tab-btn-four {
  background: var(--tab-four);
  color: var(--tab-four-text);
}

#tab-btn-model {
  background: var(--tab-model);
  color: var(--tab-model-text);
}

#tab-btn-info {
  background: var(--tab-info);
  color: var(--tab-info-text);
}

.panel-host {
  position: relative;
  z-index: 2;
  min-height: 480px;
  background: var(--panel);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: 18px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel-head {
  margin-bottom: 13px;
}

.panel-head h2 {
  margin: 0 0 4px;
  font-size: 22px;
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 500;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.4;
  font-weight: 300;
}

.token-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(150px, 0.8fr) minmax(140px, 0.8fr);
  gap: 13px;
  align-items: stretch;
}

.soft-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
}

.metric-card {
  min-height: 126px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.credits-card {
  justify-content: space-between;
  align-items: stretch;
  text-align: left;
}

.metric-label {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.3;
  font-weight: 500;
}

.metric-label-centered {
  text-align: center;
}

.metric-content {
  color: var(--text);
  font-size: 16px;
  font-weight: 300;
}

.action-card {
  align-items: center;
  text-align: center;
}

.action-card-content {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#token-input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 13px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

#token-input {
  min-height: 50px;
  padding: 0 12px;
  font-size: 16px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  font-weight: 300;
}

#token-input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

textarea {
  min-height: 140px;
  resize: vertical;
  padding: 16px;
  font-size: 20px;
  line-height: 1.5;
  margin-bottom: 13px;
  font-weight: 300;
}

#token-input:focus,
textarea:focus {
  border-color: rgba(110, 110, 120, 0.2);
}

.credits-value {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.credits-value-centered {
  text-align: center;
}

.upload-title {
  display: block;
  margin-bottom: 6px;
  color: var(--muted-2);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.upload-shell {
  padding: 11px;
}

.single-upload-shell {
  margin-bottom: 13px;
  width: 100%;
  max-width: 270px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.custom-dropzone {
  width: 100%;
  min-height: 130px;
  padding: 11px;
  border: 1.5px dashed rgba(120, 120, 128, 0.28);
  border-radius: 13px;
  background: var(--surface-soft);
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.square-dropzone {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  overflow: hidden;
}

#panel-four .upload-grid {
  grid-template-columns: repeat(2, minmax(180px, 270px));
  justify-content: center;
}

#panel-four .upload-shell {
  width: 100%;
  max-width: 270px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.custom-dropzone:hover {
  transform: translateY(-1px);
}

.custom-dropzone .dz-message {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.4;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 16px;
  text-align: center;
  font-weight: 300;
}

.custom-dropzone.dz-started .dz-message {
  display: none;
}

.custom-dropzone .dz-preview {
  position: relative;
  margin: 0;
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  border-radius: 11px;
  overflow: hidden;
  background: transparent;
}

.custom-dropzone .dz-preview .dz-image {
  width: 100%;
  height: 100%;
  border-radius: 11px;
  overflow: hidden;
  background: transparent;
}

.custom-dropzone .dz-preview .dz-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.custom-dropzone .dz-preview .dz-details,
.custom-dropzone .dz-preview .dz-size,
.custom-dropzone .dz-preview .dz-filename,
.custom-dropzone .dz-preview .dz-progress,
.custom-dropzone .dz-preview .dz-success-mark,
.custom-dropzone .dz-preview .dz-error-mark,
.custom-dropzone .dz-preview .dz-error-message {
  display: none !important;
}

.custom-dropzone .dz-preview .dz-remove {
  position: absolute;
  right: 7px;
  bottom: 7px;
  z-index: 10;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #ffffff;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  backdrop-filter: blur(6px);
}

.custom-dropzone .dz-preview .dz-remove:hover {
  background: rgba(0, 0, 0, 0.82);
}

.viewer-tone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.viewer-tone-label {
  color: var(--muted-2);
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
}

.viewer-tone-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  max-width: 195px;
  height: 32px;
  border-radius: 999px;
  background: var(--toggle-bg);
  border: 1px solid var(--toggle-border);
  box-shadow: var(--shadow-soft);
  padding: 0 3px;
  cursor: pointer;
}

.viewer-tone-slider::-webkit-slider-runnable-track {
  height: 24px;
  background: transparent;
  border-radius: 999px;
}

.viewer-tone-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: 0;
  border: none;
  border-radius: 50%;
  background: var(--toggle-thumb);
  box-shadow: var(--shadow-soft);
}

.viewer-tone-slider::-moz-range-track {
  height: 24px;
  background: transparent;
  border-radius: 999px;
}

.viewer-tone-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: var(--toggle-thumb);
  box-shadow: var(--shadow-soft);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
  align-items: center;
  justify-content: center;
  margin-top: 13px;
}

.panel-actions-model {
  flex-wrap: nowrap;
}

.primary-action,
.secondary-action {
  min-height: 46px;
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.16s ease, opacity 0.16s ease;
  font-size: 16px;
  font-weight: 500;
}

.primary-action:hover,
.secondary-action:hover {
  transform: translateY(-1px);
}

.primary-action {
  background: var(--primary-bg);
  color: var(--primary-text);
}

.secondary-action {
  background: var(--secondary-bg);
  color: var(--secondary-text);
}

.primary-token-tab {
  background: var(--tab-token);
  color: var(--tab-token-text);
}

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

.primary-image-tab {
  background: var(--tab-image);
  color: var(--tab-image-text);
}

.primary-four-tab {
  background: var(--tab-four);
  color: var(--tab-four-text);
}

.primary-model-tab {
  background: var(--tab-model);
  color: var(--tab-model-text);
}

.large-button {
  min-width: 156px;
}

#download-stl-btn.stl-ready {
  background: var(--tab-model);
  color: var(--tab-model-text);
}

.generate-btn:disabled,
.primary-action:disabled,
.secondary-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.viewer-shell {
  position: relative;
  min-height: 372px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--viewer-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  margin-bottom: 12px;
}

#viewer {
  display: block;
  width: 100%;
  height: 372px;
  background: transparent;
}

.viewer-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
  font-weight: 300;
}

.viewer-shell.has-model .viewer-placeholder {
  display: none;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.info-block {
  padding: 14px;
}

.info-block h3 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.12;
  font-weight: 500;
}

.info-block p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
  font-weight: 300;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-overlay.hidden {
  display: none;
}

.loading-status-bar {
  position: relative;
  width: min(88vw, 520px);
  min-height: 58px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: var(--shadow-card);
}

body[data-theme="dark"] .loading-status-bar {
  background: rgba(30, 30, 34, 0.92);
  border-color: rgba(255, 255, 255, 0.08);
}

.loading-status-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--tab-model);
  transition: width 0.2s linear;
}

.loading-status-text-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.loading-status-text {
  position: absolute;
  inset: 0;
  min-height: 58px;
  padding: 0 18px;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

.loading-status-text-dark {
  color: #161416;
  z-index: 1;
}

.loading-status-text-light {
  color: #ffffff;
  z-index: 2;
  mix-blend-mode: difference;
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .side-tab {
    width: 50px;
    min-height: 52px;
  }

  .side-tab.active {
    width: 68px;
    min-height: 62px;
  }

  .token-layout {
    grid-template-columns: 1fr;
  }

  .panel-actions-model {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 8px 10px 10px;
  }

  .site-header {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 8px;
  }

  .brand-left {
    gap: 10px;
  }

  .brand-logo {
    height: 50px;
  }

  .brand-text h1 {
    font-size: 32px;
  }

  .header-center,
  .header-right {
    justify-content: flex-start;
  }

  .global-status {
    min-height: 40px;
    min-width: 0;
    width: 100%;
    padding: 8px 10px;
    font-size: 15px;
  }

  .theme-toggle-track {
    width: 54px;
    height: 31px;
  }

  .theme-toggle-thumb {
    top: 3px;
    left: 3px;
    width: 23px;
    height: 23px;
  }

  body[data-theme="dark"] .theme-toggle-thumb {
    left: 28px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .tab-rail {
    flex-direction: row;
    align-items: stretch;
    gap: 8px;
    padding: 0;
    overflow-x: auto;
  }

  .tab-info {
    margin-top: 0;
    margin-left: auto;
  }

  .side-tab {
    width: auto;
    min-width: 74px;
    min-height: 46px;
    border-radius: 14px;
    padding: 8px 12px;
    flex: 0 0 auto;
  }

  .side-tab.active {
    width: auto;
    min-width: 82px;
    min-height: 46px;
  }

  .side-tab span {
    writing-mode: horizontal-tb;
    font-size: 15px;
  }

  .panel-host {
    padding: 13px;
    border-radius: 15px;
    min-height: 380px;
  }

  .panel-head h2,
  .info-block h3 {
    font-size: 20px;
  }

  .panel-head p,
  .metric-content,
  #token-input,
  .upload-title,
  .viewer-tone-label,
  .custom-dropzone .dz-message,
  .primary-action,
  .secondary-action,
  .global-status,
  .loading-status-text,
  .viewer-placeholder,
  .info-block p {
    font-size: 15px;
  }

  textarea {
    min-height: 132px;
    font-size: 22px;
  }

  .metric-label,
  .upload-title,
  .viewer-tone-label {
    font-size: 15px;
  }

  .upload-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  #panel-four .upload-grid {
    grid-template-columns: 1fr;
  }

  #panel-four .upload-shell {
    max-width: 100%;
  }

  .single-upload-shell {
    max-width: 100%;
  }

  .viewer-tone-row {
    flex-direction: column;
    align-items: stretch;
  }

  .viewer-tone-slider {
    max-width: none;
  }

  #viewer,
  .viewer-shell {
    height: 280px;
    min-height: 280px;
  }

  .large-button {
    min-width: 100%;
  }

  .custom-dropzone .dz-preview .dz-remove {
    right: 6px;
    bottom: 6px;
    min-height: 22px;
    padding: 0 8px;
    font-size: 13px;
  }

  .loading-status-bar {
    width: min(92vw, 520px);
    min-height: 54px;
  }

  .loading-status-text {
    min-height: 54px;
    padding: 0 14px;
  }
}