:root {
  --paper: #f6f3ea;
  --ink: #111;
  --muted: #6c6a63;
  --line: #171717;
  --lime: #d9ff45;
  --cyan: #7de8ff;
  --red: #ff5a5a;
  --panel: #fffdf7;
  --shadow: 8px 8px 0 #111;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(17, 17, 17, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(17, 17, 17, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  font-family:
    "Avenir Next Condensed",
    "DIN Condensed",
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.mast {
  min-height: 168px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 4px solid var(--line);
  padding-bottom: 18px;
}

.eyebrow,
.label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(48px, 8vw, 112px);
  line-height: 0.86;
  font-weight: 900;
}

h2 {
  font-size: 24px;
  line-height: 1;
}

.ticker {
  min-width: 180px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px solid var(--line);
  background: var(--lime);
  box-shadow: 4px 4px 0 #111;
  font-weight: 800;
}

.ticker-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #111;
}

.ticker.busy {
  background: var(--cyan);
}

.ticker.error {
  background: var(--red);
  color: #111;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 18px;
  margin-top: 22px;
}

.panel {
  border: 3px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.input-panel {
  min-height: 522px;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.input-panel .panel-head {
  flex-wrap: wrap;
  align-items: center;
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-actions button,
.social-copy-panel .ghost {
  min-height: 44px;
  flex-shrink: 0;
}

.input-actions button:focus-visible,
.social-copy-panel .ghost:focus-visible,
.switch input:focus-visible + span {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.input-actions button:hover:not(:disabled),
.social-copy-panel .ghost:hover:not(:disabled) {
  background: var(--lime);
}

.input-actions button:disabled,
.social-copy-panel .ghost:disabled {
  cursor: default;
  color: var(--muted);
  background: var(--paper);
}

.translation-controls {
  margin-bottom: 18px;
}

.translation-controls .switch {
  min-height: 44px;
  cursor: pointer;
}

.translation-controls .control-hint {
  margin: 4px 0 0;
}

.output-language {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.english-copy {
  margin-top: 18px;
}

.icon-button,
.ghost,
.primary {
  border: 2px solid var(--line);
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 900;
}

textarea {
  flex: 1;
  width: 100%;
  min-height: 270px;
  resize: vertical;
  border: 2px solid var(--line);
  background: #111;
  color: #fdfbf5;
  padding: 18px;
  outline: none;
  line-height: 1.55;
  font-family:
    "SF Mono",
    "Menlo",
    "PingFang SC",
    monospace;
  font-size: 15px;
}

textarea:focus {
  box-shadow: inset 0 0 0 3px var(--lime);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0;
}

.select-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}

select {
  height: 40px;
  border: 2px solid var(--line);
  background: #fff;
  padding: 0 12px;
  color: var(--ink);
  font-weight: 900;
}

.audio-speed-controls input {
  width: 84px;
  min-height: 44px;
  border: 2px solid var(--line);
  background: #fff;
  padding: 0 10px;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
}

.audio-speed-controls input:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.control-hint {
  margin: -4px 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 900;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  width: 44px;
  height: 24px;
  border: 2px solid var(--line);
  background: #fff;
  position: relative;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: #111;
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--lime);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.primary {
  width: 100%;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--lime);
  padding: 0 18px;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 4px 4px 0 #111;
}

.primary:disabled {
  cursor: wait;
  background: #ddd8ca;
}

/* Account access follows the toolbox's paper, ink and lime palette. */
.login-page {
  display: grid;
  place-items: center;
  padding: 48px 20px;
}

.login-shell {
  width: min(100%, 440px);
}

.login-heading {
  margin-bottom: 28px;
}

.login-heading h1 {
  font-size: clamp(36px, 8vw, 52px);
  line-height: 1.1;
  text-wrap: balance;
}

.login-heading p,
.login-note {
  color: var(--muted);
  line-height: 1.6;
}

.login-heading p {
  margin: 12px 0 0;
}

.login-form {
  padding: clamp(22px, 5vw, 32px);
}

.login-form h2 {
  margin-bottom: 26px;
}

.login-field {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.login-field label {
  font-weight: 800;
}

.login-field input {
  min-width: 0;
  width: 100%;
  height: 48px;
  border: 2px solid var(--line);
  border-radius: 0;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  caret-color: var(--ink);
  font-size: 16px;
}

.login-field input:focus-visible,
.login-form button:focus-visible,
.logout-button:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}

.login-field input:focus-visible {
  background: #f5ffd0;
}

.login-field input[aria-invalid="true"] {
  border-color: #a32222;
}

.login-error {
  margin: 0 0 20px;
  color: #a32222;
  line-height: 1.5;
}

.login-form .primary {
  justify-content: center;
}

.login-form .primary:hover:not(:disabled),
.logout-button:hover:not(:disabled) {
  background: var(--cyan);
}

.login-note {
  margin: 20px 0 0;
  font-size: 14px;
}

.mast-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.logout-button {
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.logout-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.progress-panel {
  min-height: 242px;
}

.billing-panel {
  min-height: 232px;
}

.cost-pill {
  min-width: 104px;
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  background: var(--cyan);
  padding: 0 10px;
  font-size: 18px;
  font-weight: 900;
  text-align: center;
}

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

.billing-grid div {
  min-height: 76px;
  border: 2px solid var(--line);
  background: #fff;
  padding: 10px;
}

.billing-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.billing-grid strong {
  display: block;
  font-size: 15px;
  line-height: 1.35;
}

.percent {
  min-width: 78px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  background: #111;
  color: var(--lime);
  font-size: 22px;
  font-weight: 900;
}

.progress-track {
  height: 22px;
  border: 2px solid var(--line);
  background: #fff;
  margin: 8px 0 18px;
  overflow: hidden;
}

.progress-track div {
  width: 0;
  height: 100%;
  background: repeating-linear-gradient(
    -45deg,
    var(--lime),
    var(--lime) 10px,
    #111 10px,
    #111 14px
  );
  background-size: 36px 36px;
  transition: width 220ms ease;
}

.progress-track.is-loading div {
  animation: progressFlow 680ms linear infinite;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.32);
}

.progress-track.is-completed div {
  background: var(--lime);
}

.progress-track.is-failed div {
  background: var(--red);
}

@keyframes progressFlow {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 36px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .progress-track.is-loading div {
    animation: none;
  }
}

.steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.steps li {
  min-height: 76px;
  display: flex;
  align-items: end;
  border: 2px solid var(--line);
  background: #fff;
  padding: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.steps li[data-status="running"] {
  background: var(--cyan);
  color: #111;
}

.steps li[data-status="completed"] {
  background: var(--lime);
  color: #111;
}

.steps li[data-status="failed"] {
  background: var(--red);
  color: #111;
}

.result-panel {
  min-height: 262px;
}

.ghost {
  min-width: 58px;
  height: 34px;
  background: #fff;
  font-weight: 900;
}

.output {
  min-height: 174px;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  border: 2px solid var(--line);
  background: #111;
  color: #fdfbf5;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family:
    "SF Mono",
    "Menlo",
    "PingFang SC",
    monospace;
  font-size: 14px;
  line-height: 1.55;
}

.assets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.assets a {
  border: 2px solid var(--line);
  background: #fff;
  color: #111;
  padding: 10px 14px;
  text-decoration: none;
  font-weight: 900;
  box-shadow: 3px 3px 0 #111;
}

/* --- Tool selection homepage --- */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 18px;
  border: 3px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px 22px;
  text-decoration: none;
  color: var(--ink);
  transition: transform 80ms ease, box-shadow 80ms ease;
}

.tool-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 10px 10px 0 #111;
}

.tool-card:active {
  transform: translate(2px, 2px);
  box-shadow: 4px 4px 0 #111;
}

.tool-icon {
  min-width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 3px solid var(--line);
  background: var(--lime);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.tool-info h2 {
  margin-bottom: 6px;
}

.tool-info p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.tool-arrow {
  margin-left: auto;
  font-size: 28px;
  font-weight: 900;
  flex-shrink: 0;
}

/* --- Breadcrumb --- */

.breadcrumb {
  color: var(--muted);
  text-decoration: none;
  transition: color 100ms;
}

.breadcrumb:hover {
  color: var(--ink);
}

/* --- Drop zone --- */

.drop-zone {
  flex: 1;
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 3px dashed var(--line);
  background: #faf8f2;
  cursor: pointer;
  transition: background 100ms, border-color 100ms;
}

.drop-zone.has-files {
  min-height: 80px;
  flex: 0;
}

.drop-zone.drag-over {
  background: var(--lime);
  border-color: #111;
}

.drop-zone-inner {
  text-align: center;
  padding: 18px;
}

.drop-zone-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border: 3px solid var(--line);
  background: #fff;
  font-size: 28px;
  font-weight: 900;
}

.drop-zone-inner p {
  margin: 0 0 4px;
  font-weight: 800;
  font-size: 15px;
}

.drop-zone-link {
  color: var(--ink);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 900;
}

.drop-zone-hint {
  color: var(--muted);
  font-size: 13px !important;
  font-weight: 600 !important;
}

/* --- Image preview grid --- */

.image-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 0;
}

.image-preview-grid:empty {
  display: none;
}

.preview-item {
  position: relative;
  width: 88px;
  border: 2px solid var(--line);
  background: #fff;
}

.preview-item img {
  display: block;
  width: 100%;
  height: 72px;
  object-fit: cover;
}

.preview-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  background: var(--red);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.preview-name {
  display: block;
  padding: 3px 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Image analyze extras --- */

.input-panel textarea {
  flex: none;
  min-height: 56px;
  margin-top: 12px;
}

.result-panel-wide {
  grid-column: 1 / -1;
}

.output-tall {
  min-height: 300px;
  max-height: 600px;
}

/* --- Share card overlay --- */

.panel-head-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.ghost-accent {
  background: var(--lime) !important;
}

.ghost-accent:disabled {
  background: #ddd8ca !important;
  cursor: default;
}

.card-overlay[hidden] {
  display: none;
}

.card-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: start;
  justify-content: center;
  padding: 24px 16px 40px;
  overflow-y: auto;
}

.card-overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.card-wrapper {
  position: relative;
  width: min(420px, calc(100vw - 32px));
}

.card-toolbar {
  display: flex;
  gap: 6px;
  justify-content: end;
  margin-bottom: 10px;
}

.card-toolbar .ghost {
  border-color: #fff;
  color: #fff;
  background: transparent;
  font-size: 13px;
  height: 30px;
  min-width: auto;
  padding: 0 10px;
}

.card-toolbar .ghost-accent {
  background: var(--lime) !important;
  color: var(--ink) !important;
  border-color: var(--line) !important;
}

.share-card {
  background:
    linear-gradient(90deg, rgba(17, 17, 17, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(17, 17, 17, 0.06) 1px, transparent 1px),
    #f6f3ea;
  background-size: 34px 34px;
  border: 3px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.share-card-accent {
  height: 8px;
  background: repeating-linear-gradient(
    -45deg,
    #d9ff45,
    #d9ff45 10px,
    #111 10px,
    #111 14px
  );
}

.share-card-body {
  padding: 22px 22px 14px;
  margin: 14px 14px 0;
  background: #fffdf7;
  border: 2px solid #171717;
  font-size: 15px;
  line-height: 1.75;
  color: #111;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

.share-card-body > *:last-child {
  margin-bottom: 0;
}

.share-card-body h1,
.share-card-body h2,
.share-card-body h3,
.share-card-body h4 {
  font-family: "Avenir Next Condensed", "DIN Condensed", "PingFang SC", sans-serif;
  line-height: 1.3;
  margin: 18px 0 8px;
  padding-bottom: 6px;
  border-bottom: 3px solid #111;
}

.share-card-body > h1:first-child,
.share-card-body > h2:first-child,
.share-card-body > h3:first-child {
  margin-top: 0;
}

.share-card-body h1 { font-size: 22px; }
.share-card-body h2 { font-size: 19px; }
.share-card-body h3 { font-size: 17px; border-bottom-width: 2px; }
.share-card-body h4 { font-size: 15px; border-bottom: none; }

.share-card-body p {
  margin: 0 0 14px;
}

.share-card-body ul,
.share-card-body ol {
  padding-left: 20px;
  margin: 0 0 14px;
}

.share-card-body li {
  margin-bottom: 6px;
}

.share-card-body li::marker {
  font-weight: 900;
}

.share-card-body hr {
  border: none;
  height: 3px;
  background: #111;
  margin: 18px 0;
}

.share-card-body blockquote {
  margin: 0 0 14px;
  padding: 12px 16px;
  border-left: 4px solid #d9ff45;
  background: #f0eee4;
  border-top: 2px solid #111;
  border-bottom: 2px solid #111;
}

.share-card-body blockquote p {
  margin: 0;
}

.share-card-body code {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 13px;
  background: #eae8de;
  padding: 2px 6px;
  border: 1px solid #171717;
}

.share-card-body pre {
  margin: 0 0 14px;
  padding: 14px;
  background: #111;
  color: #fdfbf5;
  overflow-x: auto;
  border: 2px solid #171717;
  font-size: 13px;
  line-height: 1.5;
}

.share-card-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

.share-card-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 14px;
  font-size: 14px;
}

.share-card-body th,
.share-card-body td {
  border: 2px solid #171717;
  padding: 8px 10px;
  text-align: left;
}

.share-card-body th {
  background: #d9ff45;
  font-weight: 900;
}

.share-card-body td {
  background: #fff;
}

.share-card-body strong {
  font-weight: 900;
}

.share-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  margin: 14px 14px 14px;
  border: 2px solid #171717;
  background: #111;
  color: #fdfbf5;
  box-shadow: 4px 4px 0 #111;
}

.share-card-tag {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #d9ff45;
}

.share-card-date {
  font-size: 12px;
  color: #6c6a63;
}

.copy-fallback {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

@media (max-width: 850px) {
  .mast {
    align-items: start;
    flex-direction: column;
  }

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

  .steps {
    grid-template-columns: 1fr;
  }

  .billing-grid {
    grid-template-columns: 1fr;
  }

  .steps li {
    min-height: 42px;
    align-items: center;
  }
}
