.root-shell {
  width: min(1680px, calc(100vw - 28px));
  max-width: none;
}

.root-shell,
.root-shell input,
.root-shell textarea,
.root-shell select,
.root-shell button {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.root-shell .hero {
  margin-bottom: 10px;
}

.root-hero {
  min-height: 86px;
  justify-content: space-between;
  gap: 18px;
  border-radius: 16px;
}

.root-hero h1 {
  text-align: left;
  font-family: inherit;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: 0;
}

.root-hero p {
  max-width: 560px;
  margin: 7px 0 0;
  color: rgba(238, 246, 255, 0.7);
  line-height: 1.45;
}

.top-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.top-links a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: rgba(238, 246, 255, 0.78);
  text-decoration: none;
  font-weight: 650;
}

.top-links a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.task-console {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid rgba(20, 22, 29, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 20px rgba(6, 10, 20, 0.04);
}

.task-user-box,
.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.task-user-box span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid rgba(20, 22, 29, 0.08);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.task-user-box {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(180px, 0.75fr) minmax(140px, 0.55fr) auto auto auto;
}

.task-user-box.is-authenticated {
  grid-template-columns: minmax(220px, 1fr) auto;
}

.task-user-box.is-authenticated #auth-email,
.task-user-box.is-authenticated #auth-password,
.task-user-box.is-authenticated #auth-login,
.task-user-box.is-authenticated #auth-register {
  display: none;
}

.task-actions {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) auto minmax(220px, 0.7fr) auto;
}

.task-console input,
.task-console select {
  width: auto;
  min-width: 150px;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.88rem;
}

.task-actions {
  justify-content: start;
}

.task-actions #task-name {
  min-width: 220px;
}

.task-status {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.auth-gate {
  width: min(520px, calc(100vw - 28px));
  margin: 8vh auto 0;
}

.auth-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(20, 22, 29, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 40px rgba(6, 10, 20, 0.16);
}

.auth-card h1 {
  text-align: left;
  font-family: inherit;
  font-size: 1.5rem;
  letter-spacing: 0;
}

.auth-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

.auth-gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid rgba(94, 106, 210, 0.18);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,248,255,0.94));
}

.admin-panel[hidden] {
  display: none;
}

.admin-panel-head,
.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-panel-head h2 {
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0;
}

.admin-panel-head span,
.admin-user-row em {
  color: #4d58b8;
  font-size: 0.8rem;
  font-style: normal;
  font-weight: 700;
}

.admin-user-list {
  display: grid;
  gap: 6px;
}

.admin-user-row {
  padding: 8px 10px;
  border: 1px solid rgba(20, 22, 29, 0.08);
  border-radius: 8px;
  background: #fff;
}

.admin-user-row span {
  color: var(--muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.root-layout {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.root-layout > .panel {
  min-width: 0;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(20, 22, 29, 0.1);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 20px rgba(6, 10, 20, 0.04);
}

.root-input-panel,
.template-panel,
.candidate-panel {
  min-height: 0;
}

.root-input-panel {
  grid-column: 1 / -1;
  grid-row: auto;
}

.template-panel {
  grid-column: 1 / -1;
  grid-row: auto;
}

.candidate-panel {
  grid-column: 1 / -1;
  grid-row: auto;
}

.result-panel {
  grid-column: 1 / -1;
  padding: 0;
  overflow: hidden;
}

.result-panel > .panel-header {
  margin: 0;
  padding: 14px;
  border-bottom: 1px solid rgba(20, 22, 29, 0.08);
  background: linear-gradient(180deg, #ffffff, #f8f9fc);
}

.panel-header {
  align-items: center;
  margin-bottom: 12px;
}

.panel-header h2 {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 720;
  letter-spacing: 0;
  white-space: nowrap;
}

.section-kicker {
  margin-bottom: 5px;
  letter-spacing: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: #5e6ad2;
}

.inline-actions {
  gap: 8px;
}

.root-input-panel .panel-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}

.inline-actions .button,
.file-button {
  min-height: 36px;
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 680;
  line-height: 1.2;
}

.root-input-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.45fr);
  align-items: start;
  gap: 12px;
}

.input-mode-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(20, 22, 29, 0.08);
  border-radius: 10px;
  background: #fbfcfe;
}

.input-mode-head {
  display: grid;
  gap: 3px;
}

.input-mode-head strong {
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 760;
  line-height: 1.25;
}

.input-mode-head small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.root-input-grid textarea {
  min-height: 260px;
}

.upload-card,
.upload-stack {
  display: grid;
  gap: 10px;
}

.upload-card {
  align-content: start;
}

.upload-card .button.primary {
  width: 100%;
}

.file-picker {
  display: grid;
  position: relative;
  min-height: 42px;
  overflow: hidden;
  border: 1px dashed rgba(94, 106, 210, 0.28);
  border-radius: 9px;
  background: rgba(94, 106, 210, 0.05);
  cursor: pointer;
}

.file-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-picker span {
  display: grid;
  place-items: center;
  color: #3f4ca7;
  font-size: 0.88rem;
  font-weight: 720;
}

.upload-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(94, 106, 210, 0.07);
  border-color: rgba(94, 106, 210, 0.12);
  color: #4d58b8;
  font-size: 0.72rem;
  line-height: 1.3;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-list {
  display: grid;
  gap: 6px;
  max-height: 136px;
  overflow: auto;
}

.file-list-head,
.file-list-item {
  padding: 7px 8px;
  border: 1px solid rgba(20, 22, 29, 0.08);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.file-list-head {
  color: var(--ink);
  font-weight: 700;
}

.template-panel {
  overflow: hidden;
}

.category-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  padding-right: 2px;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.55fr) minmax(150px, 1fr);
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(20, 22, 29, 0.08);
  border-radius: 10px;
  background: #fbfcfe;
}

.category-row label {
  gap: 4px;
  color: #4f5666;
  font-size: 0.78rem;
  font-weight: 650;
}

.category-row input,
.category-row textarea {
  font-size: 0.84rem;
}

.category-row textarea {
  min-height: 58px;
}

.category-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

.candidate-panel .panel-header {
  display: grid;
  gap: 8px;
}

.root-counts {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.root-counts span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid rgba(20, 22, 29, 0.08);
  border-radius: 8px;
  background: #fff;
  color: #4f5666;
}

.candidate-columns {
  display: grid;
  grid-template-columns: minmax(170px, 0.72fr) minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 10px;
  align-items: stretch;
}

.candidate-columns h3 {
  margin-bottom: 7px;
  font-size: 0.86rem;
  font-weight: 720;
}

.candidate-columns > div,
.candidate-summary {
  min-width: 0;
}

.candidate-summary {
  padding: 10px;
  border: 1px solid rgba(20, 22, 29, 0.08);
  border-radius: 10px;
  background: #fbfcfe;
}

.token-list {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  min-height: 120px;
  max-height: 164px;
  overflow: auto;
  padding: 8px;
  border: 1px solid rgba(20, 22, 29, 0.08);
  border-radius: 10px;
  background: #fbfcfe;
}

.candidate-panel .token-list {
  min-height: 366px;
  max-height: 560px;
}

.token-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid rgba(94, 106, 210, 0.12);
  background: rgba(94, 106, 210, 0.07);
  color: #454ea5;
  font-size: 0.76rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.batch-status {
  min-height: 0;
  padding: 10px 14px 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.root-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(190px, 1fr));
  gap: 0;
  padding: 14px;
  overflow-x: auto;
}

.root-column {
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto;
  gap: 8px;
  min-width: 190px;
  min-height: 420px;
  padding: 10px;
  border: 1px solid rgba(20, 22, 29, 0.08);
  border-right: 0;
  background: #fff;
}

.root-column:first-child {
  border-radius: 10px 0 0 10px;
}

.root-column:last-child {
  border-right: 1px solid rgba(20, 22, 29, 0.08);
  border-radius: 0 10px 10px 0;
}

.root-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(20, 22, 29, 0.08);
}

.root-column-head h3 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 760;
}

.root-column-head span {
  min-width: 26px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(94, 106, 210, 0.1);
  color: #4d58b8;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 760;
}

.root-column-list {
  display: grid;
  align-content: start;
  gap: 5px;
  max-height: 560px;
  overflow: auto;
}

.root-cell {
  display: grid;
  gap: 4px;
  padding: 5px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f7f8fb;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.root-cell:hover,
.root-cell:focus-within {
  border-color: rgba(94, 106, 210, 0.24);
  background: #fff;
}

.root-cell input,
.root-cell select {
  min-height: 28px;
  padding: 4px 6px;
  border-radius: 6px;
  background: #fff;
  font-size: 0.84rem;
}

.root-cell input {
  border-color: transparent;
  background: transparent;
  font-weight: 700;
}

.root-cell-meta {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.root-cell-meta:empty {
  display: none;
}

.root-cell-actions {
  display: none;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
}

.root-cell:hover .root-cell-actions,
.root-cell:focus-within .root-cell-actions {
  display: grid;
}

.mini-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(20, 22, 29, 0.14);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.add-row-button {
  width: 100%;
  min-height: 32px;
  border: 1px dashed rgba(94, 106, 210, 0.3);
  border-radius: 8px;
  background: rgba(94, 106, 210, 0.05);
  color: #3f4ca7;
  font-weight: 720;
  cursor: pointer;
}

.root-details {
  margin: 0 14px 14px;
  border-radius: 10px;
}

.warning-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--danger);
  font-size: 0.86rem;
}

@media (max-width: 900px) {
  .task-console,
  .task-user-box,
  .task-actions {
    grid-template-columns: 1fr;
  }

  .task-actions {
    justify-content: flex-start;
  }

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

  .category-editor {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .candidate-panel .token-list {
    min-height: 160px;
    max-height: 260px;
  }

  .root-board {
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 10px;
  }

  .root-column,
  .root-column:first-child,
  .root-column:last-child {
    border: 1px solid rgba(20, 22, 29, 0.08);
    border-radius: 10px;
  }
}

@media (max-width: 820px) {
  .root-shell {
    width: min(100% - 20px, 720px);
  }

  .root-layout,
  .root-input-grid,
  .candidate-columns {
    grid-template-columns: 1fr;
  }

  .root-input-panel,
  .template-panel,
  .candidate-panel {
    grid-column: 1;
    grid-row: auto;
    min-height: 0;
  }

  .root-hero {
    align-items: flex-start;
  }

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

  .category-editor {
    max-height: none;
  }
}
