:root {
  color-scheme: light;
  --background: #f6f7f4;
  --text: #18201c;
  --muted: #607068;
  --line: #cfd8d2;
  --panel: #ffffff;
  --panel-alt: #eef4f7;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #a33a2a;
  --danger-bg: #fbe8e3;
  --shadow: 0 18px 45px rgba(24, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

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

button:hover:not(:disabled) {
  border-color: var(--accent);
}

.app {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
}

.status,
.message {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
}

.status.ready,
.message.ok {
  color: var(--accent-strong);
}

.status.error,
.message.error {
  color: var(--danger);
}

.tabs {
  display: inline-flex;
  gap: 4px;
  margin: 20px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
}

.tab {
  min-width: 96px;
  border-color: transparent;
  background: transparent;
}

.tab.active {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(24, 32, 28, 0.08);
}

.workspace {
  display: none;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.workspace.active {
  display: block;
}

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

.primary {
  min-width: 112px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

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

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.span-2 {
  grid-column: 1 / -1;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

pre.hex-output {
  width: 100%;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fbfa;
  color: var(--text);
  padding: 12px;
}

textarea:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

textarea {
  min-height: 170px;
  resize: vertical;
  padding: 12px;
  line-height: 1.45;
}

input {
  min-height: 42px;
  padding: 0 12px;
}

textarea[readonly] {
  background: #f9fbfa;
}

.hex-output,
.report-output {
  min-height: 150px;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
}

.hex-byte.hidden {
  border-radius: 3px;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 700;
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.actions button {
  padding: 0 14px;
}

@media (max-width: 760px) {
  .app {
    width: min(100vw - 20px, 1120px);
    padding-top: 14px;
  }

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

  .tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .tab,
  .primary {
    width: 100%;
  }

  .workspace {
    padding: 16px;
  }

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

  .span-2 {
    grid-column: auto;
  }
}
