:root {
  color-scheme: light;
  --bg: #f7fbff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbeafe;
  --line-strong: #bfdbfe;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eff6ff;
  --green: #047857;
  --green-soft: #ecfdf5;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --shadow: 0 16px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(239, 246, 255, 0.94), rgba(255, 255, 255, 0.98) 44%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.shell {
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 20px;
}

.top-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.top-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
}

.brand-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.brand-title,
.brand-badges {
  display: inline-flex;
  align-items: center;
}

.brand-title {
  min-width: 0;
  gap: 10px;
}

.brand-badges {
  flex-wrap: wrap;
  gap: 8px;
}

.brand-icon {
  display: inline-flex;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background:
    radial-gradient(circle at 68% 24%, rgba(255, 255, 255, 0.9), transparent 23px),
    linear-gradient(145deg, #dbeafe 0%, #eff6ff 55%, #ffffff 100%);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.14);
}

.brand-icon svg {
  width: 34px;
  height: 34px;
}

.brand-icon-shield {
  fill: var(--blue);
}

.brand-icon-lock {
  fill: white;
  stroke: white;
}

.brand-icon-shackle {
  fill: none;
}

.brand-icon-spark {
  fill: #86efac;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  line-height: 1.2;
}

h2 {
  font-size: 1rem;
  line-height: 1.3;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--blue-soft);
  padding: 0 12px;
  color: var(--blue-dark);
  font-size: 0.75rem;
  font-weight: 700;
}

.pill-green {
  border-color: #bbf7d0;
  background: var(--green-soft);
  color: var(--green);
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(210px, auto) minmax(180px, auto) minmax(210px, auto) minmax(210px, auto);
  gap: 12px;
}

.control label,
.field-label,
.label-row span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.control label {
  display: block;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 40px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #f8fafc;
  padding: 4px;
}

.operation-button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #475569;
  font-size: 0.9rem;
  font-weight: 800;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.operation-button.is-active {
  background: var(--blue);
  color: white;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.22);
}

.fixed-control,
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 40px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #f8fafc;
  padding: 0 12px;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 800;
}

.switch {
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.switch[aria-checked="true"] {
  border-color: var(--line-strong);
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.switch-track {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 150ms ease;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: white;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.22);
  transition: left 150ms ease;
}

.switch[aria-checked="true"] .switch-track {
  background: var(--blue);
}

.switch[aria-checked="true"] .switch-thumb {
  left: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.panel {
  padding: 18px;
}

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

.panel-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.button-row,
.input-row {
  display: flex;
  gap: 8px;
}

.button,
.icon-button,
.inline-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-weight: 800;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.button {
  height: 38px;
  border: 1px solid #e2e8f0;
  padding: 0 12px;
  font-size: 0.88rem;
}

.button-primary {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
}

.button-primary:hover {
  background: var(--blue-dark);
}

.button-secondary,
.icon-button {
  background: white;
  color: #475569;
}

.button-secondary:hover,
.icon-button:hover,
.inline-button:hover {
  border-color: #93c5fd;
  color: var(--blue-dark);
}

.icon-button {
  flex: 0 0 auto;
  height: 38px;
  min-width: 48px;
  border: 1px solid #e2e8f0;
  padding: 0 10px;
  font-size: 0.78rem;
}

.inline-button {
  position: absolute;
  top: 4px;
  right: 4px;
  height: 30px;
  border: 0;
  background: transparent;
  padding: 0 8px;
  color: #64748b;
  font-size: 0.78rem;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #334155;
  font-size: 0.9rem;
}

.code-area,
.text-input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: white;
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.code-area {
  min-height: 320px;
  max-height: 540px;
  overflow: auto;
  padding: 12px;
  line-height: 1.55;
  resize: none;
}

.output-area,
.text-input[readonly] {
  background: #f8fafc;
}

.text-input {
  height: 38px;
  padding: 0 11px;
}

.code-area:focus,
.text-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(147, 197, 253, 0.35);
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.key-shell {
  position: relative;
  min-width: 0;
  flex: 1 1 auto;
}

.key-input {
  padding-right: 58px;
}

.status {
  display: flex;
  align-items: center;
  min-height: 40px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--blue-soft);
  padding: 9px 12px;
  color: var(--blue-dark);
  font-size: 0.9rem;
  font-weight: 700;
}

.status-success {
  border-color: #bbf7d0;
  background: var(--green-soft);
  color: var(--green);
}

.status-error {
  border-color: #fecaca;
  background: var(--red-soft);
  color: var(--red);
}

.tag-field {
  margin-top: 18px;
}

.notice {
  margin-top: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #f8fafc;
  padding: 9px 12px;
  color: #475569;
  font-size: 0.9rem;
  font-weight: 700;
}

::selection {
  background: #bfdbfe;
  color: var(--text);
}

@media (max-width: 1120px) {
  .top-panel {
    align-items: stretch;
    flex-direction: column;
  }

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

@media (max-width: 880px) {
  .workspace,
  .field-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .shell {
    padding: 12px;
  }

  .top-panel,
  .panel {
    padding: 14px;
  }

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

  .brand-title {
    width: 100%;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row {
    width: 100%;
  }

  .button-row .button {
    flex: 1;
  }

  .input-row {
    flex-wrap: wrap;
  }

  .input-row .text-input,
  .input-row .key-shell {
    flex-basis: 100%;
  }
}
