* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #0f172a;
  color: #e5e7eb;
}

.tool-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: #020617;
  border-bottom: 1px solid #1e293b;
}

.tool-header > div {
  min-width: 0;
}

.tool-header h1 {
  margin: 8px 0 4px;
  font-size: clamp(23px, 7vw, 32px);
  white-space: nowrap;
}

.tool-header p {
  margin: 0;
  color: #94a3b8;
}

@media (max-width: 430px) {
  .tool-header h1 {
    font-size: 27px;
  }

  .tool-header p {
    font-size: 13px;
    line-height: 1.35;
  }
}

.back-link {
  color: #38bdf8;
  text-decoration: none;
  font-size: 14px;
  font-weight: bold;
}

.status-pill {
  background: #064e3b;
  color: #a7f3d0;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: bold;
}

.tool-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.tool-card {
  background: #111827;
  border: 1px solid #263244;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.eyebrow {
  color: #38bdf8;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: bold;
}

.tool-card h2 {
  margin: 12px 0 22px;
  font-size: 26px;
}

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #cbd5e1;
  font-weight: bold;
}

input,
select {
  width: 100%;
  background: #020617;
  color: #e5e7eb;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 15px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.image-drop-zone:focus-visible,
.download-image-button:focus-visible,
.download-data-button:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.28);
  outline-offset: 2px;
}

input[type="range"] {
  padding: 0;
  height: 44px;
  accent-color: #38bdf8;
  cursor: pointer;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

#cubeInputs .input-row {
  grid-template-columns: repeat(3, 1fr);
}

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

button {
  padding: 12px 18px;
  background: #38bdf8;
  color: #020617;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  font-weight: bold;
}

button:hover {
  background: #67e8f9;
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.secondary-btn {
  background: #1e293b;
  color: #e5e7eb;
  border: 1px solid #334155;
}

.secondary-btn:hover {
  background: #334155;
}

.conversion-selector-card {
  grid-column: 1 / -1;
  padding: 28px;
}

.conversion-selector-card h2 {
  margin-bottom: 6px;
}

.selector-intro {
  margin: 0 0 22px;
  color: #94a3b8;
  line-height: 1.5;
}

.converter-tile-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 13px;
}

.converter-tile {
  position: relative;
  min-width: 0;
  min-height: 164px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 17px 10px;
  border: 1px solid #334155;
  border-radius: 18px;
  background: linear-gradient(160deg, #101a2b, #080f1e);
  color: #e5e7eb;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.converter-tile:hover {
  border-color: #64748b;
  background: linear-gradient(160deg, #142137, #0a1324);
  transform: translateY(-2px);
}

.converter-tile.active {
  border-color: #38bdf8;
  background: linear-gradient(160deg, rgba(14, 165, 233, 0.2), rgba(8, 15, 30, 0.96));
  box-shadow:
    0 0 0 2px rgba(56, 189, 248, 0.13),
    0 13px 30px rgba(14, 165, 233, 0.16);
}

.converter-tile-icon {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border: 1px solid #334155;
  border-radius: 17px;
  background: #020617;
  color: #67e8f9;
  font-size: 29px;
  font-weight: bold;
  line-height: 1;
}

.converter-data-icon {
  font-size: 20px;
}

.converter-tile.active .converter-tile-icon {
  border-color: rgba(56, 189, 248, 0.62);
  background: rgba(2, 6, 23, 0.72);
}

.converter-tile-name {
  max-width: 100%;
  color: #f8fafc;
  font-size: 14px;
  font-weight: bold;
  line-height: 1.2;
  text-align: center;
}

.converter-tile-description {
  color: #7f8da3;
  font-size: 11px;
  font-weight: normal;
  line-height: 1.25;
  text-align: center;
}

.selected-check {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 23px;
  height: 23px;
  display: none;
  place-items: center;
  border-radius: 999px;
  background: #38bdf8;
  color: #020617;
  font-size: 13px;
  font-weight: bold;
}

.converter-tile.active .selected-check {
  display: grid;
}

.result-box {
  background: #020617;
  border: 1px solid #334155;
  border-radius: 18px;
  padding: 26px;
  margin-bottom: 22px;
}

.result-box p {
  margin: 0 0 12px;
  color: #94a3b8;
}

.result-box strong {
  display: block;
  color: #67e8f9;
  font-size: 34px;
  word-break: break-word;
}

.quick-reference {
  background: #020617;
  border: 1px solid #263244;
  border-radius: 18px;
  padding: 20px;
}

.quick-reference h3 {
  margin-top: 0;
  color: #e5e7eb;
}

.quick-reference ul {
  padding-left: 20px;
  color: #94a3b8;
  line-height: 1.8;
}

.data-input-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.data-input-heading > label {
  margin: 0;
}

.data-file-picker {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #1e293b;
  color: #e5e7eb;
  cursor: pointer;
  font-size: 13px;
}

.data-file-picker:hover {
  border-color: #38bdf8;
  background: #273449;
}

.data-textarea {
  width: 100%;
  min-height: 285px;
  resize: vertical;
  padding: 15px;
  border: 1px solid #334155;
  border-radius: 14px;
  outline: none;
  background: #020617;
  color: #dbeafe;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
}

.data-helper {
  margin: 8px 0 18px;
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.45;
}

.data-result-toolbar {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 10px 13px;
  border: 1px solid #263244;
  border-radius: 12px;
  background: #020617;
}

.data-result-toolbar > div span,
.data-result-toolbar > div strong {
  display: block;
}

.data-result-toolbar > div span {
  margin-bottom: 3px;
  color: #64748b;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.data-result-toolbar > div strong {
  color: #67e8f9;
  font-size: 15px;
}

.data-status {
  color: #94a3b8;
  font-size: 12px;
  text-align: right;
}

.data-status.success {
  color: #a7f3d0;
}

.data-status.error {
  color: #fca5a5;
}

.output-textarea {
  min-height: 365px;
}

.data-output-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.data-action-button,
.download-data-button {
  flex: 1 1 0;
}

.data-action-button:disabled {
  cursor: not-allowed;
}

.download-data-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 12px;
  background: #38bdf8;
  color: #020617;
  font-size: 15px;
  font-weight: bold;
  text-align: center;
  text-decoration: none;
}

.download-data-button:hover {
  background: #67e8f9;
}

.download-data-button.hidden {
  display: none;
}

.data-note {
  display: grid;
  gap: 4px;
  margin-top: 16px;
  padding: 13px 15px;
  border-left: 3px solid #10b981;
  border-radius: 0 12px 12px 0;
  background: rgba(16, 185, 129, 0.08);
}

.data-note strong {
  color: #a7f3d0;
  font-size: 13px;
}

.data-note span {
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.45;
}

.image-drop-zone {
  min-height: 175px;
  margin-bottom: 16px;
  border: 2px dashed #334155;
  border-radius: 18px;
  background: #020617;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.image-drop-zone:hover,
.image-drop-zone.drag-over {
  border-color: #38bdf8;
  background: #071427;
  transform: translateY(-1px);
}

.image-drop-zone strong {
  font-size: 17px;
  color: #e5e7eb;
}

.image-drop-zone > span:last-child {
  max-width: 360px;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.45;
}

.drop-zone-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.13);
  color: #67e8f9;
  font-size: 27px;
  line-height: 1;
}

.selected-file-card {
  position: relative;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid #334155;
  border-radius: 15px;
  background: #0b1220;
}

.selected-file-card.hidden {
  display: none;
}

.selected-file-preview {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #334155;
  border-radius: 12px;
  background: #020617;
  color: #67e8f9;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 0.8px;
}

.selected-file-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selected-file-copy {
  min-width: 0;
}

.selected-file-copy strong,
.selected-file-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file-copy strong {
  margin-bottom: 5px;
  color: #e5e7eb;
}

.selected-file-copy span {
  color: #94a3b8;
  font-size: 13px;
}

.remove-file-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #1e293b;
  color: #cbd5e1;
  font-size: 22px;
  line-height: 1;
}

.remove-file-button:hover {
  background: #7f1d1d;
  color: #fee2e2;
}

.image-output-options {
  align-items: end;
}

#qualityValue {
  color: #67e8f9;
}

.image-privacy-note {
  display: grid;
  gap: 4px;
  margin: 4px 0 18px;
  padding: 13px 15px;
  border-left: 3px solid #10b981;
  border-radius: 0 12px 12px 0;
  background: rgba(16, 185, 129, 0.08);
}

.image-privacy-note strong {
  color: #a7f3d0;
  font-size: 13px;
}

.image-privacy-note span {
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.45;
}

.image-result-placeholder {
  min-height: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 30px;
  border: 2px dashed #263244;
  border-radius: 18px;
  background: #020617;
  text-align: center;
}

.image-result-placeholder > span {
  color: #38bdf8;
  font-size: 48px;
  line-height: 1;
}

.image-result-placeholder strong {
  color: #e5e7eb;
  font-size: 18px;
}

.image-result-placeholder p {
  max-width: 370px;
  margin: 0;
  color: #94a3b8;
  line-height: 1.5;
}

.image-result-placeholder.error {
  border-color: #7f1d1d;
  background: rgba(127, 29, 29, 0.12);
}

.image-result-placeholder.error > span,
.image-result-placeholder.error strong {
  color: #fca5a5;
}

.converted-image-card {
  display: grid;
  gap: 18px;
}

.converted-image-card.hidden {
  display: none;
}

.converted-preview-wrap {
  min-height: 330px;
  max-height: 520px;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 18px;
  border: 1px solid #334155;
  border-radius: 18px;
  background-color: #020617;
  background-image:
    linear-gradient(45deg, #111827 25%, transparent 25%),
    linear-gradient(-45deg, #111827 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #111827 75%),
    linear-gradient(-45deg, transparent 75%, #111827 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.converted-preview-wrap img {
  display: block;
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
}

.conversion-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.conversion-summary-grid > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid #263244;
  border-radius: 12px;
  background: #020617;
}

.conversion-summary-grid span,
.conversion-summary-grid strong {
  display: block;
}

.conversion-summary-grid span {
  margin-bottom: 5px;
  color: #64748b;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.conversion-summary-grid strong {
  overflow: hidden;
  color: #e5e7eb;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-image-button {
  display: block;
  padding: 14px 18px;
  border-radius: 12px;
  background: #38bdf8;
  color: #020617;
  font-weight: bold;
  text-align: center;
  text-decoration: none;
}

.download-image-button:hover {
  background: #67e8f9;
}

.hidden {
  display: none;
}

footer {
  text-align: center;
  padding: 20px;
  color: #64748b;
}

@media (max-width: 980px) {
  .converter-tile-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 850px) {
  .tool-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
  }

  .tool-layout {
    grid-template-columns: 1fr;
  }

  .input-row,
  #cubeInputs .input-row {
    grid-template-columns: 1fr;
  }

  .conversion-summary-grid {
    grid-template-columns: 1fr;
  }

  .converted-preview-wrap,
  .image-result-placeholder {
    min-height: 270px;
  }
}

@media (max-width: 520px) {
  .tool-layout {
    padding: 14px;
  }

  .tool-card {
    padding: 18px;
    border-radius: 16px;
  }

  .conversion-selector-card {
    padding: 18px;
  }

  .converter-tile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .converter-tile {
    min-height: 144px;
    padding: 14px 7px;
    border-radius: 15px;
  }

  .converter-tile-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    font-size: 25px;
  }

  .converter-data-icon {
    font-size: 18px;
  }

  .button-row {
    flex-direction: column;
  }

  .button-row button {
    width: 100%;
  }

  .data-output-actions {
    flex-direction: column;
  }

  .data-result-toolbar {
    align-items: flex-start;
  }

  .data-status {
    max-width: 55%;
  }

  .data-textarea,
  .output-textarea {
    min-height: 250px;
  }

  .image-drop-zone {
    min-height: 150px;
    padding: 18px 14px;
  }

  .selected-file-card {
    grid-template-columns: 52px minmax(0, 1fr) 34px;
  }

  .selected-file-preview {
    width: 52px;
    height: 52px;
  }
}



.bottom-back-container {
  max-width: 1100px;
  margin: 0 auto 20px;
  padding: 0 20px;
}

.bottom-back-button {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;

  background: #111827;
  border: 1px solid #263244;

  color: #38bdf8;
  text-decoration: none;

  padding: 18px 24px;

  border-radius: 18px;

  font-size: 18px;
  font-weight: bold;

  transition: 0.2s ease;
}

.bottom-back-button:hover {
  border-color: #38bdf8;

  background: #1e293b;

  transform: translateY(-2px);

  box-shadow: 0 12px 30px rgba(56, 189, 248, 0.12);
}
