:root {
  --red:        #cc0000;
  --dark:       #1a1a1a;
  --gray:       #444;
  --light-gray: #f5f5f5;
  --border:     #ddd;
  --white:      #fff;
  --muted:      #666;
  --green:      #2e7d32;
  --warn-bg:    #fff8e1;
  --warn-border:#f9a825;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--light-gray);
  color: var(--dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--dark);
  color: var(--white);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  height: 60px;
  border-bottom: 3px solid var(--red);
  flex-shrink: 0;
}
header .logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--white);
  text-decoration: none;
}
header .logo span { color: var(--red); }
header nav {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
header nav a {
  color: #ccc;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 5px 12px;
  border: 1px solid #555;
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
header nav a:hover { color: var(--white); border-color: #aaa; }

/* ── Breadcrumb ── */
.breadcrumb {
  padding: 0.75rem 2rem;
  font-size: 0.875rem;
  color: var(--gray);
  border-bottom: 1px solid var(--border);
  background: #f9f9f9;
  flex-shrink: 0;
}
.breadcrumb a { color: var(--red); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ── Layout ── */
main.page {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 16px;
}
.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.page-subtitle {
  color: var(--muted);
  margin-bottom: 28px;
  font-size: 0.95rem;
}

/* ── Footer ── */
footer {
  background: var(--light-gray);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.5rem 2rem;
  color: var(--gray);
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}
footer a { color: var(--red); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Card ── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

/* ── Tool grid (hub page) ── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.tool-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  gap: 16px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tool-card:hover {
  border-color: var(--red);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.tool-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
  width: 40px;
  text-align: center;
  color: var(--red);
}
.tool-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 6px;
}
.tool-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 10px;
}
.tool-formats { font-size: 0.8rem; }

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  color: var(--muted);
}
.drop-zone:hover, .drop-zone.dragging {
  background: #fff3f3;
  border-color: var(--red);
  color: var(--dark);
}
.drop-zone.uploading {
  background: #f5f5f5;
  border-color: #bbb;
  cursor: wait;
}
.drop-zone .icon { font-size: 2.5rem; margin-bottom: 12px; }
.drop-zone p { font-size: 0.95rem; }
.drop-zone small { font-size: 0.78rem; margin-top: 6px; display: block; }

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 9px 20px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--red); color: var(--white); }
.btn-outline {
  background: transparent;
  color: var(--dark);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--gray); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.link-btn { color: var(--red); cursor: pointer; text-decoration: underline; }

/* ── Badges ── */
.badge {
  display: inline-block;
  background: #eee;
  color: var(--gray);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-family: monospace;
}
.badge-green { background: #e8f5e9; color: var(--green); }

/* ── Alerts ── */
.alert {
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-top: 12px;
}
.alert-error { background: #fdecea; border: 1px solid #f5c6cb; color: #c0392b; }
.alert-warn  { background: var(--warn-bg); border: 1px solid var(--warn-border); color: #5a4000; }
.alert-info  { background: #e8f4fd; border: 1px solid #bee3f8; color: #1a5276; }

/* ── Group slot grid ── */
.block-section { margin-bottom: 24px; }
.block-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.rearrange-header { margin-bottom: 20px; }
.rearrange-title  { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }
.rearrange-hint   { font-size: 0.875rem; color: var(--muted); line-height: 1.5; }

.slots-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}
.slots-half {
  display: flex;
  gap: 4px;
}
.slot-label-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}
.slot-label {
  width: 22px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.slots-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.slot-item {
  height: 32px;
  display: flex;
  align-items: center;
}
.group-card {
  flex: 1;
  height: 30px;
  background: var(--light-gray);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: grab;
  user-select: none;
  min-width: 0;
  transition: background 0.1s, border-color 0.1s;
}
.group-card:hover { background: #e8e8e8; border-color: #bbb; }
.slot-item.drag-over { outline: 2px solid var(--red); outline-offset: -2px; border-radius: 4px; }
.slot-empty-card {
  flex: 1;
  height: 30px;
  border: 1px dashed #e0e0e0;
  border-radius: 4px;
}
.group-tag   { font-weight: 600; font-size: 0.82rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-mnets { font-size: 0.74rem; color: var(--muted); font-family: monospace; white-space: nowrap; flex-shrink: 0; }
.group-types { font-size: 0.70rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; }

/* ── Tool list (single-column with problem/solution) ── */
.tool-list { display: flex; flex-direction: column; gap: 16px; }
.tool-list-item {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  align-items: start;
  text-decoration: none;
  color: var(--dark);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tool-list-item:hover {
  border-color: var(--red);
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.tool-list-item:hover .tool-name { color: var(--red); }
.tool-list-left { display: flex; }
.tool-card-inner {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.tool-list-right { font-size: 0.875rem; line-height: 1.6; }
.tool-list-right p + p { margin-top: 8px; }
.tool-list-right .problem-label { font-weight: 600; color: var(--dark); }
.tool-list-right .solution-label { font-weight: 600; color: var(--red); }
.suite-overview {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--dark);
}
.suite-overview h2 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
@media (max-width: 680px) {
  .tool-list-item { grid-template-columns: 1fr; gap: 12px; }
  .slots-grid { grid-template-columns: 1fr; }
  .slots-half:last-child { margin-top: 8px; }
}

/* ── Info table ── */
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.info-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--gray);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.info-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

/* ── Docs ── */
.doc-list {
  padding-left: 20px;
  line-height: 2;
  font-size: 0.93rem;
}
.doc-list li { margin-bottom: 4px; }
.muted-text { color: var(--muted); font-size: 0.88rem; }

/* ── Bug report link ── */
.bug-link-wrap { text-align: right; margin: 6px 0 -4px; }
.bug-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  color: var(--muted);
  text-decoration: none;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  transition: color 0.15s, border-color 0.15s;
}
.bug-link:hover { color: var(--danger); border-color: #e88; }
.bug-link--inline { margin-left: auto; }

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid #ddd;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Square tool cards (hub page) ── */
.tool-grid-square {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.tool-card-square {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 20px 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: var(--dark);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  position: relative;
  min-height: 185px;
  aspect-ratio: 1 / 1;
}
.tool-card-square:hover {
  border-color: var(--red);
  box-shadow: 0 3px 12px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}
.tool-card-square.highlighted {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46,125,50,0.15);
  background: #f1f8f1;
}
.tool-card-square.highlighted:hover {
  border-color: var(--green);
  box-shadow: 0 3px 14px rgba(46,125,50,0.2);
}
.tool-card-square.warning-flash {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 4px rgba(204,0,0,0.2) !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tool-card-square .tool-icon-sq {
  font-size: 2.2rem;
  margin-bottom: 12px;
  color: var(--red);
  flex-shrink: 0;
  line-height: 1;
}
.tool-card-square.highlighted .tool-icon-sq { color: var(--green); }
.tool-card-square .tool-name-sq {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.tool-card-square .tool-formats-sq {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: auto;
  flex-shrink: 0;
}
.tool-card-square .info-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--light-gray);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  margin: 0;
}
.tool-card-square .info-btn:hover {
  background: var(--dark);
  color: var(--white);
}

/* Info popup overlay */
.info-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: popupFadeIn 0.15s ease;
}
.info-popup {
  background: var(--white);
  border-radius: 12px;
  padding: 28px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.info-popup h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--dark);
}
.info-popup .problem-label { font-weight: 600; color: var(--dark); }
.info-popup .solution-label { font-weight: 600; color: var(--red); }
.info-popup p {
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 10px;
}
.info-popup .close-popup {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 20px;
  background: var(--dark);
  color: var(--white);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Resume Session card (wide, short, above tool grid on hub page) */
.resume-card {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 16px;
}
.resume-card:hover {
  border-color: var(--red);
  box-shadow: 0 3px 12px rgba(0,0,0,0.1);
}
.resume-card.highlighted {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46,125,50,0.15);
  background: #f1f8f1;
}
.resume-card .resume-icon {
  font-size: 1.6rem;
  color: var(--muted);
  flex-shrink: 0;
}
.resume-card.highlighted .resume-icon { color: var(--green); }
.resume-card .resume-body { flex: 1; }
.resume-card .resume-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 2px;
}
.resume-card .resume-hint {
  font-size: 0.82rem;
  color: var(--muted);
}
.resume-card.highlighted .resume-title { color: var(--green); }

@keyframes popupFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Floating save button ── */
.float-save-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: 50px;
  padding: 12px 22px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(204,0,0,0.3);
  z-index: 900;
  display: none;
  align-items: center;
  gap: 7px;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
}
.float-save-btn.visible { display: flex; }
.float-save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(204,0,0,0.4);
}
.float-save-btn .save-icon { font-size: 1rem; }

/* ── Editable controller name ── */
.ctrl-name-input {
  font-weight: 700;
  font-size: 1rem;
  border: 1px solid var(--border);
  background: var(--light-gray);
  padding: 2px 6px;
  border-radius: 4px;
  max-width: 350px;
  min-width: 100px;
  transition: border-color 0.15s, background 0.15s;
  color: var(--dark);
}
.ctrl-name-input:hover {
  border-color: var(--gray);
  background: #e8e8e8;
}
.ctrl-name-input:focus {
  outline: none;
  border-color: var(--red);
  background: var(--white);
}

/* ── Inline group tag editing ── */
.group-tag {
  position: relative;
}
.group-tag-edit {
  position: absolute;
  inset: 0;
  z-index: 10;
  border: 2px solid var(--red);
  border-radius: 3px;
  padding: 0 4px;
  font-weight: 600;
  font-size: 0.82rem;
  font-family: inherit;
  background: var(--white);
  color: var(--dark);
  outline: none;
  min-width: 60px;
}

/* ── Back to tools link ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--red);
  text-decoration: none;
  font-weight: 600;
  margin-bottom: 18px;
  transition: opacity 0.15s;
}
.back-link:hover { opacity: 0.8; }

/* ── Tool instructions card ── */
.instruct-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--dark);
}
.instruct-card .instruct-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

/* ── Responsive hub cards ── */
@media (max-width: 900px) {
  .tool-grid-square { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
