* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: white;
  padding: 40px 20px;
  color: #333;
  overflow-x: hidden;
}
.container {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
@media (max-width: 768px) {
  body { padding: 20px; }
}
@media (max-width: 480px) {
  body { padding: 15px; }
}
.date-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.nav-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  padding: 0;
}
.nav-btn:hover { color: #000; }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

input[type="text"] {
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  font-size: 14px;
  background: #f5f5f5;
  color: #333;
  font-family: inherit;
}
input[type="text"]:focus {
  outline: none;
  border-color: #999;
  background: #fafafa;
}
.lang-input {
  width: 100px;
  margin-left: 15px;
}
.category {
  position: relative; /* for category overlay */
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  min-width: 0;
}
@media (max-width: 480px) {
  .category { gap: 8px; }
}
.color-square-wrapper {
  position: relative;
  flex-shrink: 0;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.color-square {
  width: 20px;
  height: 20px;
  border-radius: 2px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}
.color-square:hover {
  border-color: #333;
  transform: scale(1.1);
}
.color-square.yellow { background: #FFE384; }
.color-square.coral  { background: #FF927C; }
.color-square.mint   { background: #9EDEBE; }
.color-square.sky    { background: #71C2FA; }

.color-arrow {
  font-size: 10px;
  color: #999;
  cursor: pointer;
  user-select: none;
}
.color-square-wrapper:hover .color-arrow {
  color: #666;
}
.color-dropdown {
  position: absolute;
  top: 28px;
  left: 0;
  z-index: 100;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: none;
  padding: 4px;
}
.color-dropdown.show {
  display: flex;
  flex-direction: row;
  gap: 4px;
}
.color-option {
  width: 20px;
  height: 20px;
  border-radius: 2px;
  cursor: pointer;
  display: block;
  border: 1px solid rgba(0,0,0,0.2);
  flex-shrink: 0;
}
.color-option:hover {
  transform: scale(1.15);
  border-color: #333;
}

.category-content {
  flex: 1;
  min-width: 0;
}
.category-name-input {
  flex: 1;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  background: #f5f5f5;
  font-size: 14px;
  box-sizing: border-box;
  min-width: 0;
}
@media (max-width: 480px) {
  .category-name-input {
    padding: 10px;
    font-size: 13px;
  }
}
.words-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.word-input {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  background: #f5f5f5;
  font-size: 13px;
  text-transform: uppercase;
  box-sizing: border-box;
}
@media (max-width: 600px) {
  .word-input {
    flex: 0 0 calc(50% - 5px);
    min-width: calc(50% - 5px);
  }
}
@media (max-width: 400px) {
  .word-input {
    flex: 0 0 calc(50% - 5px);
    font-size: 12px;
    padding: 8px;
  }
}
.word-input.duplicate {
  background: #ffe6e6;
  border-color: #dc3545;
  color: #721c24;
}

.category-header {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}
.category-header .name-input-wrapper {
  flex: 1;
  min-width: 0;
}
.category-header .category-name-input {
  margin-bottom: 0;
}
@media (max-width: 480px) {
  .category-header { gap: 8px; }
  .regenerate-btn {
    min-width: 40px;
    padding: 10px;
  }
}

.regenerate-btn,
.ban-btn {
  background-color: #74bdee;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.regenerate-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.regenerate-btn:hover,
.ban-btn:hover {
  background: #4782a9;
  border-color: #999;
}

.ban-btn {
  height: 32px;
  width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#generateBtn {
  background: #8b5cf6 !important;
  color: white !important;
  border: 1px solid #7c3aed !important;
  transition: all 0.2s ease !important;
}

#generateBtn:hover {
  background: #7c3aed !important;
  border-color: #6d28d9 !important;
}

/* Title block (title + date subtitle) */
.title-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.date-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.date-label-text {
  font-family: monospace;
  font-size: 12px;
  color: #aaa;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
/* Flatpickr wrapper — anchor for the ▼ arrow */
.flatpickr-wrapper {
  position: relative !important;
  display: inline-block !important;
}
.flatpickr-wrapper::after {
  content: '▼';
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  color: #777;
  pointer-events: none;
  z-index: 2;
}

/* ── Calendar day states ─────────────────────────────────────────────────── */

/* Past date with a published puzzle — gray */
.flatpickr-day.fp-past-published,
.flatpickr-day.fp-past-published:hover {
  background: #ebebeb !important;
  color: #aaa !important;
  border-color: transparent !important;
}

/* Future date waiting to be published — green, dark text */
.flatpickr-day.fp-upcoming,
.flatpickr-day.fp-upcoming:hover {
  background: #dcfce7 !important;
  color: #166534 !important;
  border-color: transparent !important;
}

/* Today — orange dot below the number, no border override */
.flatpickr-day.today,
.flatpickr-day.today:hover {
  border-color: transparent !important;
  position: relative;
}
.flatpickr-day.today::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #e67e22;
}

/* Selected date — blue ring only, no fill; text in same blue */
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.selected:focus {
  background: transparent !important;
  border: 2px solid #2471a3 !important;
  color: #2471a3 !important;
  box-shadow: none !important;
}

/* Selected + upcoming: keep green bg, add blue ring */
.flatpickr-day.selected.fp-upcoming,
.flatpickr-day.selected.fp-upcoming:hover {
  background: #dcfce7 !important;
  border: 2px solid #2471a3 !important;
  color: #166534 !important;
}

/* Selected + past-published: keep gray bg, add blue ring */
.flatpickr-day.selected.fp-past-published,
.flatpickr-day.selected.fp-past-published:hover {
  background: #ebebeb !important;
  border: 2px solid #2471a3 !important;
  color: #555 !important;
}

/* Selected + today: blue ring, keep orange dot */
.flatpickr-day.selected.today,
.flatpickr-day.selected.today:hover {
  border: 2px solid #2471a3 !important;
  color: #2471a3 !important;
}

.publish-date-picker {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #555;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0 10px;
  width: 110px;
  text-align: center;
  height: 40px;
  box-sizing: border-box;
  background: #f5f5f5;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}
.publish-date-picker:hover,
.publish-date-picker:focus { border-color: #999; background: #fafafa; }

/* Past-snapshot mode: amber tint to distinguish from future-date selection */
.publish-date-picker.past-mode {
  border-color: #d4a04a;
  background: #fdf6e8;
  color: #a07030;
}

/* Button to jump back to the next available future date */
.jump-to-next-btn {
  padding: 0 14px;
  height: 40px;
  box-sizing: border-box;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
  background: #e67e22;
  color: white;
}
.jump-to-next-btn:hover { background: #d35400; }

@media (max-width: 480px) {
  .publish-date-picker { height: 36px; font-size: 13px; }
  .jump-to-next-btn    { height: 36px; font-size: 13px; }
}

.date-mask {
  font-size: 10px;
  color: #ccc;
  letter-spacing: 3px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e0e0e0;
  gap: 15px;
  position: relative; /* anchor for #messageArea overlay */
}

.title {
  font-family: 'Press Start 2P', cursive;
  font-size: 20px;        /* slightly smaller so it fits beside buttons */
  font-weight: normal;
  color: #2c3e50;
  line-height: 1.6;
  margin: 0;
  white-space: nowrap;    /* never break the title */
}

/* Tablet and below: stack title-block on top, buttons row below */
@media (max-width: 900px) {
  .top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    position: relative; /* anchor for absolutely-positioned lock btn */
  }
  .title-block {
    flex: none;
    width: 100%;
    align-items: flex-start;
  }
  .title { text-align: left; }
  .date-row { justify-content: flex-start; }
  .actions { width: 100%; justify-content: center; flex-wrap: nowrap; }
  .action-btn { flex: 1; min-width: 0; }
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
  position: relative; /* anchor for auth-panel overlay on desktop */
}
.action-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  white-space: nowrap;
}
/* Small phones — must come AFTER base .action-btn rule to win the cascade */
@media (max-width: 600px) {
  .title { font-size: 14px; }
  .actions { gap: 4px; align-items: stretch; }
  .action-btn { padding: 10px 0; font-size: 11px; font-weight: 500; }
  .lock-btn { padding: 0 8px; font-size: 14px; }
}
.action-btn.save {
  background: #74bdee;
  color: white;
}
.action-btn.save:hover { background: #2980b9; }
.action-btn.reload {
  background: #e74c3c;
  color: white;
}
.action-btn.reload:hover { background: #c0392b; }

/* Disabled state for all action buttons */
.action-btn:disabled:not(.loading):not(.success) {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Notification overlay — centered on top-bar's border-bottom divider */
.message-area {
  position: absolute;
  bottom: -1px;        /* -1px = outer edge of the 1px border */
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  transform: translateY(50%);
  z-index: 20;
  pointer-events: none;
}

.message-box {
  padding: 14px 40px;   /* 180% taller than the original 8px */
  border-radius: 6px;
  font-size: 13px;
  line-height: 1;
  color: #1f2933;
  background-color: #e0f2fe;
  border: 1px solid #7fb1e8;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
}

/* optional variants */
.message-box.success {
  background-color: #dcfce7;
  border-color: #4ade80;
  color: #166534;
}

.message-box.error {
  background-color: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.message-box.info {
  background-color: #e0f2fe;
  border-color: #7fb1e8;
  color: #1d4ed8;
}

.design-notes {
  margin-top: 12px;
  padding: 14px 16px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  color: #999;
  font-size: 14px;
  line-height: 1.8;
  width: 100%;
  box-sizing: border-box;
}
.design-notes.locked {
  background: #f9f9f9;
  opacity: 0.65;
}

.status {
  position: fixed;
  bottom: 20px;
  right: 20px;
  font-size: 11px;
  color: #999;
}
.status-select {
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  font-size: 14px;
  background: #f5f5f5;
  color: #333;
  font-family: inherit;
  margin-left: 10px;
  cursor: pointer;
}

.validation-errors {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 4px;
  padding: 12px 16px;
  margin-bottom: 20px;
  color: #856404;
}
.validation-errors.has-errors {
  background: #f8d7da;
  border-color: #dc3545;
  color: #721c24;
}
.validation-errors ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
}
.validation-errors li { margin: 4px 0; }

.puzzle-content {
  margin-top: 8px;
  min-width: 0;
  max-width: 100%;
}
@media (max-width: 480px) {
  .puzzle-content { margin-top: 20px; }
}

/* wrapper for full‑puzzle overlay */
.puzzle-container {
  position: relative;
}

/* full‑puzzle overlay */
.puzzle-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.puzzle-overlay.show {
  display: flex;
}
.puzzle-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #374151;
}

/* per‑category overlay */
.category-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 150;
}
.category-overlay.show {
  display: flex;
}
.category-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #374151;
}

.overlay-label {
  margin-top: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.action-btn.export {
  background: #27ae60;
  color: white;
}
.action-btn.export:hover { background: #229954; }
.action-btn.export:disabled {
  background: #95a5a6;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Loading + success states for action buttons */
.action-btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}
.action-btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.action-btn.success {
  position: relative;
  color: transparent;
  background: #27ae60 !important;
}

.action-btn.success::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 18px;
  font-weight: bold;
}

/* ── Lock button ──────────────────────────────────────────────────── */
.lock-btn {
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
  padding: 10px 10px;   /* same vertical padding as .action-btn */
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
  flex-shrink: 0;
  position: relative;   /* sit above the auth-panel overlay */
  z-index: 6;
}
.lock-btn:hover { background: #f0f0f0; border-color: #bbb; }
.lock-btn.unlocked { border-color: #27ae60; background: #f0fdf4; }

/* ── Inline auth panel — overlays the action buttons ─────────────── */
.auth-panel {
  display: none;
  position: absolute;
  inset: 0;
  background: white;
  align-items: center;
  gap: 8px;
  z-index: 5;
  padding-right: 50px; /* don't visually bleed into the lock button */
}
.auth-panel.show { display: flex; }

.auth-panel input[type="password"] {
  flex: 1;
  align-self: stretch;
  padding: 0 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}
.auth-panel input[type="password"]:focus { border-color: #8b5cf6; }

/* Read-only dimming for inputs */
.word-input:disabled,
.category-name-input:disabled {
  opacity: 0.65;
  cursor: default;
  background: #f9f9f9;
}

.regenerate-btn:disabled,
.ban-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── View-mode banner (shown when editor is locked) ───────────────── */
.view-mode-banner {
  width: 100%;
  padding: 9px 20px;
  background: #475569;
  color: #e2e8f0;
  font-size: 0.88rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-align: center;
  border-bottom: 1px solid #64748b;
  margin-bottom: 8px;
}
.view-mode-banner strong {
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.view-mode-banner a {
  color: #93c5fd;
  text-decoration: underline;
}

/* ── Masked content (locked view) — ● circle style matches date mask ────────── */
.word-input.masked,
.category-name-input.masked,
.design-notes .masked {
  font-size: 10px;
  color: #ccc;
  letter-spacing: 3px;
  user-select: none;
  pointer-events: none;
}

/* ── Mechanic bar locked state ───────────────────────────────────────────────── */
.mechanic-bar.mb-locked {
  opacity: 0.35;
  pointer-events: none;
}

/* ── Mechanic label (overlaid inside category name input) ───────────────────── */
.name-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.name-input-wrapper .category-name-input {
  flex: 1;
  padding-right: 120px; /* room for the label on desktop */
}
.mechanic-label {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  font-weight: 700;
  color: #555;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

/* On mobile: drop the label below the input field */
@media (max-width: 480px) {
  .name-input-wrapper .category-name-input {
    padding-right: 12px; /* restore normal padding */
    margin-bottom: 4px;
  }
  .mechanic-label {
    position: static;
    transform: none;
    display: block;
    padding: 0 2px 6px;
    font-size: 13px;
  }
}

/* ── Mechanic usage bar ─────────────────────────────────────────────────────── */
.mechanic-bar {
  background: #1a1a1a;
  border: 1px solid #2e2e2e;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #ccc;
}
.mb-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  margin-bottom: 10px;
  user-select: none;
}
.mb-toggle-row:hover .mb-heading { color: #888; }
.mb-heading {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mb-chevron {
  font-size: 9px;
  color: #555;
  flex-shrink: 0;
}
.mb-row {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin-bottom: 0;
}
.mb-tier-item {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  min-width: 120px;
}
.mb-tier-label {
  font-size: 11px;
  font-weight: 700;
  min-width: 37px;
  letter-spacing: 0.02em;
  padding-right: 1px;
}
.mb-track {
  flex: 1;
  height: 8px;
  background: #2e2e2e;
  border-radius: 4px;
  overflow: hidden;
}
.mb-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.mb-pct {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
  min-width: 46px;
  text-align: right;
  padding-left: 3px;
}
.mb-detail {
  margin-top: 10px;
}
.mb-underused {
  font-size: 11px;
  color: #888;
  line-height: 1.7;
}
.mb-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 10px;
  margin: 1px 2px;
}
.mb-t2 { background: rgba(139,92,246,0.2); color: #c4b5fd; }
.mb-t3 { background: rgba(249,115,22,0.2); color: #fdba74; }
.mb-warmup {
  font-size: 11px;
  color: #f59e0b;
  margin-top: 6px;
}
.mb-loading {
  font-size: 11px;
  color: #666;
}
