:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-strong: #f0f4f7;
  --text: #18212b;
  --muted: #5e6b78;
  --line: #c8d2dc;
  --line-strong: #7f8d9a;
  --accent: #126f84;
  --accent-strong: #0c596a;
  --accent-soft: #d9f0f4;
  --warn: #8a5a00;
  --warn-bg: #fff5dc;
  --error: #9f2c2c;
  --error-bg: #fde8e8;
  --empty: #e9edf1;
  --button-fill: #e8f4f6;
  --button-line: #5ca6b5;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
.file-button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 0 12px;
}

button:hover,
.file-button:hover {
  border-color: var(--accent);
}

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

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

.app-header {
  display: flex;
  align-items: center;
  min-height: 78px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.app-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 41vw) minmax(480px, 1fr);
  gap: 16px;
  padding: 16px;
}

.input-panel,
.output-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.input-panel {
  display: grid;
  grid-template-rows: auto auto minmax(340px, 1fr) auto;
  min-height: calc(100vh - 110px);
}

.output-panel {
  padding-bottom: 12px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

h2,
h3 {
  margin: 0;
  font-weight: 700;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 14px;
  padding: 12px 12px 8px;
}

#fileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-button {
  display: inline-flex;
  align-items: center;
}

.drop-zone {
  display: grid;
  gap: 4px;
  margin: 12px;
  border: 2px dashed var(--line-strong);
  border-radius: 8px;
  background: #f7fbfc;
  cursor: pointer;
  padding: 16px;
  text-align: center;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.drop-zone-title {
  font-size: 15px;
  font-weight: 800;
}

.drop-zone-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

#inputText {
  width: 100%;
  min-width: 0;
  height: 100%;
  resize: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: none;
  padding: 12px;
  color: var(--text);
  background: #fbfcfd;
  font:
    12px/1.5 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

#inputText:focus {
  box-shadow: inset 0 0 0 2px var(--accent-soft);
}

.input-options {
  padding: 11px 12px;
  color: var(--muted);
  font-size: 13px;
}

.input-options label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.messages {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.message {
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 13px;
  line-height: 1.4;
}

.message.note {
  border: 1px solid #d9bd72;
  background: var(--warn-bg);
  color: var(--warn);
}

.message.error {
  border: 1px solid #e2a2a2;
  background: var(--error-bg);
  color: var(--error);
}

.layout-board,
.strings-board {
  border-top: 1px solid var(--line);
}

.modules {
  display: grid;
  gap: 12px;
  padding: 0 12px 12px;
}

.module {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.module-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
  font-size: 13px;
  font-weight: 700;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(var(--slot-count), minmax(86px, 1fr));
}

.slot {
  display: grid;
  grid-template-rows: 24px minmax(72px, auto);
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--button-fill);
}

.slot:last-child {
  border-right: 0;
}

.slot.empty {
  background: var(--empty);
}

.slot-id {
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.slot-name {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-align: center;
}

.slot.empty .slot-name {
  color: #7a8793;
  font-weight: 600;
}

.strings-list {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.string-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.string-label {
  padding-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.string-value {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  font:
    12px/1.45 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (max-width: 980px) {
  .app-header,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-actions {
    flex-wrap: wrap;
  }

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

  .input-panel {
    min-height: 520px;
  }
}

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

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

  .slot {
    border-bottom: 1px solid var(--line);
  }

  .slot:nth-child(2n) {
    border-right: 0;
  }

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