:root {
  --bg: #0b0d10;
  --panel: #12161a;
  --panel-soft: #171c21;
  --field: #090b0e;
  --line: #2e353d;
  --line-strong: #48525d;
  --text: #f2f5f6;
  --muted: #9ca8b0;
  --accent: #d83a42;
  --accent-soft: rgba(216, 58, 66, 0.14);
  --ok: #48b38a;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.is-embed {
  min-height: 360px;
  background: transparent;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.glick-loader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  min-height: 360px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}

body.is-embed .glick-loader {
  position: absolute;
  border-radius: 8px;
}

.glick-loader span {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(216, 58, 66, 0.24);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: glick-spin 900ms linear infinite;
}

.glick-loader strong {
  font-size: 0.95rem;
  font-weight: 650;
}

.glick-loader[hidden] {
  display: none;
}

.glick-shell {
  width: min(980px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 32px) 0;
  display: grid;
  align-content: center;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 180ms ease, transform 180ms ease;
}

body.is-embed .glick-shell {
  width: 100%;
  min-height: 360px;
  padding: 0;
}

.glick-shell.is-loaded {
  opacity: 1;
  transform: translateY(0);
}

.converter-panel {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

body.is-embed .converter-panel {
  min-height: 360px;
}

.converter-form {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.mode-control {
  width: min(100%, 300px);
  min-height: 40px;
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.mode-control label {
  min-width: 0;
  position: relative;
}

.mode-control input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.mode-control span {
  min-height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.mode-control input:checked + span {
  border-color: rgba(216, 58, 66, 0.48);
  background: var(--accent-soft);
  color: var(--text);
}

.mode-control input:focus-visible + span,
.primary-button:focus-visible,
.ghost-button:focus-visible,
textarea:focus {
  outline: 2px solid var(--ok);
  outline-offset: 2px;
}

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

.text-field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.text-field > span,
.console-header {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  line-height: 1.55;
  caret-color: var(--accent);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea:focus {
  border-color: rgba(72, 179, 138, 0.68);
  box-shadow: 0 0 0 3px rgba(72, 179, 138, 0.12);
}

textarea[readonly] {
  color: #dce5e8;
}

textarea.is-populated {
  animation: glick-result-ready 240ms ease;
}

.process-console {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.console-header {
  min-height: 34px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: #0f1317;
}

#console-state {
  color: var(--ok);
  text-transform: none;
}

#process-log {
  height: 112px;
  margin: 0;
  overflow: auto;
  padding: 10px 12px;
  color: #cfd8dc;
  font: 0.86rem/1.55 "Cascadia Mono", "Consolas", monospace;
  white-space: pre-wrap;
}

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

.primary-button,
.ghost-button {
  min-height: 40px;
  min-width: 92px;
  padding: 0 14px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 700;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.primary-button {
  border: 1px solid rgba(216, 58, 66, 0.72);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: #c4333b;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.ghost-button:hover {
  border-color: var(--line-strong);
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.status-line {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.status-line.is-error {
  color: #ff9aa6;
}

@media (max-width: 760px) {
  .glick-shell {
    width: min(100% - 20px, 980px);
    align-content: start;
  }

  .converter-form {
    padding: 14px;
  }

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

  textarea {
    min-height: 180px;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .primary-button,
  .ghost-button {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 420px) {
  .actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@keyframes glick-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes glick-result-ready {
  from {
    border-color: rgba(72, 179, 138, 0.68);
    box-shadow: 0 0 0 3px rgba(72, 179, 138, 0.12);
  }
}
