:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7fa;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

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

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

h1 {
  margin: 0 0 8px;
  font-size: 31px;
  line-height: 1.1;
}

h2 {
  margin: 0 0 14px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

p {
  margin: 0;
  color: #617084;
}

button {
  height: 38px;
  padding: 0 12px;
  border: 1px solid #c6d0dc;
  background: #ffffff;
  color: #17202a;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

button:hover {
  border-color: #6e7e90;
}

.primary {
  background: #17202a;
  color: #ffffff;
  border-color: #17202a;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.layout {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  background: #ffffff;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  padding: 16px;
}

form.panel {
  display: grid;
  gap: 12px;
}

label {
  min-width: 0;
  color: #3b4756;
  font-size: 14px;
  display: grid;
  gap: 6px;
}

.check {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.two,
.three {
  display: grid;
  gap: 12px;
}

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

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

input,
select {
  height: 36px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  padding: 0 8px;
  background: #ffffff;
  color: #17202a;
}

.previewPanel {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 12px;
}

.previewHeader {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.previewHeader h2 {
  margin-bottom: 0;
}

.iconButton {
  width: 38px;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  font-weight: 700;
}

.gridPreview {
  display: grid;
  gap: 6px;
}

.cell {
  min-height: 34px;
  border-radius: 6px;
  border: 1px solid #cbd5e0;
  background: #eef3f8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #425066;
}

.cell.first {
  background: #f5b027;
  border-color: #c9820c;
  color: #17202a;
  font-weight: 740;
}

.cell.failed {
  background: #ffe1e1;
  border-color: #d22929;
  color: #8a1111;
  font-weight: 760;
}

.cell.empty {
  border-style: dashed;
  background: #ffffff;
  color: transparent;
}

.summary {
  color: #536174;
  font-size: 14px;
}

.logSummary {
  border: 1px solid #f0b8b8;
  background: #fff4f4;
  color: #7b1e1e;
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 13px;
  line-height: 1.4;
}

.failedRetryControls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  padding: 12px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: right;
  padding: 9px 10px;
  border-bottom: 1px solid #e5ebf2;
}

th {
  background: #f8fafc;
  color: #5b6878;
  font-weight: 680;
}

th:first-child,
td:first-child {
  text-align: left;
}

.failedRow td {
  background: #fff4f4;
  color: #7b1e1e;
}

@media (max-width: 900px) {
  .app {
    width: min(100vw - 24px, 1420px);
    padding-top: 18px;
  }

  .topbar,
  .layout {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .two,
  .three {
    grid-template-columns: 1fr;
  }
}

/* ===== Tribo-Texture Study Suite — dark theme override ===== */
:root { color-scheme: dark; background: #0d1b2a; color: #e8eef5; }
body { background: #0d1b2a; color: #e8eef5; }
p { color: #9fb3c8; }
button { background: #1b3047; color: #e8eef5; border-color: #26415e; }
button:hover { border-color: #3b82f6; }
.primary { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.panel { background: #14253a; border-color: #26415e; }
label { color: #9fb3c8; }
input, select, textarea { background: #1b3047; color: #e8eef5; border-color: #26415e; }
.cell { background: #1b3047; border-color: #26415e; color: #9fb3c8; }
.cell.empty { background: #0d1b2a; }
.summary { color: #9fb3c8; }
table { color: #e8eef5; }
th { background: #1b3047; color: #9fb3c8; }
th, td { border-bottom-color: #26415e; }
.cell.failed { background: #5a1f1f; border-color: #e05c5c; color: #ffd6d6; }
.logSummary { background: #3a1c1c; border-color: #7a2e2e; color: #ffd6d6; }
.failedRow td { background: #3a1c1c; color: #ffd6d6; }

