/* Skills management page (/skills/). */

.sk-add-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: #e8e8ea;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.sk-add-btn:hover {
  background: rgba(150, 230, 190, 0.10);
  color: #b8e6f5;
  border-color: rgba(150, 230, 190, 0.3);
}

/* The image-skills header pairs a "Free characters" link-badge with the
   add button. */
.sk-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sk-free-badge {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  color: #b8e6f5;
  background: rgba(150, 230, 190, 0.10);
  border: 1px solid rgba(150, 230, 190, 0.30);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.sk-free-badge:hover {
  background: rgba(150, 230, 190, 0.18);
  border-color: rgba(150, 230, 190, 0.5);
  color: #d7f5ff;
}

.sk-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 20px 20px;
}

/* Free-characters picker subpage (/skills/characters/). */
.sk-back {
  font-size: 13px;
  color: var(--muted-2);
  text-decoration: none;
  margin-right: 4px;
}
.sk-back:hover { color: #b8e6f5; }

.skc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 16px;
  padding: 8px 20px 20px;
}

.skc-tile {
  position: relative;
  display: block;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color .15s ease, transform .12s ease;
}
.skc-tile:hover {
  border-color: rgba(150, 230, 190, 0.45);
  transform: translateY(-2px);
}
.skc-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.03);
}
.skc-overlay {
  position: absolute;
  left: 10px; right: 10px; bottom: 10px;
  padding: 7px 0;
  border-radius: 8px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 500;
  color: #06281b;
  background: #9fdcf3;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .15s ease, transform .15s ease;
  pointer-events: none;
}
.skc-tile:hover .skc-overlay { opacity: 1; transform: translateY(0); }
.skc-tile.is-adding { pointer-events: none; opacity: 0.7; }
.skc-tile.is-adding .skc-overlay { opacity: 1; transform: translateY(0); }

.sk-empty,
.sk-empty-inline {
  color: var(--muted-2);
  font-size: 13px;
}

.sk-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}
/* The row chosen as this section's default gets a subtle amber highlight. */
.sk-row.is-active-default {
  background: rgba(255, 200, 110, 0.05);
  border-color: rgba(255, 200, 110, 0.20);
}

.sk-meta { min-width: 0; flex: 1; }

/* Image-skill reference photo: a small square thumbnail on the row, and the
   picker in the add/edit modal. */
.sk-thumb {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background-color: rgba(255, 255, 255, 0.04);
  background-size: cover;
  background-position: center;
}

.sk-photo {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.sk-photo-head {
  font-size: 13px;
  color: #e8e8ea;
  margin-bottom: 10px;
}
.sk-photo-head span {
  color: var(--muted-2);
  font-size: 12px;
}
.sk-photo-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.sk-photo-preview {
  width: 84px;
  height: 84px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background-color: rgba(255, 255, 255, 0.04);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}
.sk-photo-actions {
  display: flex;
  gap: 8px;
}
.sk-photo-btn {
  height: 30px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: #e8e8ea;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.sk-photo-btn:hover { background: rgba(255, 255, 255, 0.07); }
.sk-photo-btn.danger:hover {
  color: #ffc4c4;
  border-color: rgba(255, 180, 180, 0.3);
}

.sk-headline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #e8e8ea;
  margin-bottom: 4px;
}

.sk-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  color: #ffe1a6;
  background: rgba(255, 200, 110, 0.10);
  border: 1px solid rgba(255, 200, 110, 0.30);
}
/* "Built-in" is a neutral, read-only marker — distinct from the amber
   ★ Default state, which signals the user's own chosen default. */
.sk-badge.built-in {
  color: var(--muted-2);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
}

/* Per-section default control on each skill row. */
.sk-default-btn {
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: #e8e8ea;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.sk-default-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.07); }
.sk-default-btn.is-on {
  color: #ffe1a6;
  background: rgba(255, 200, 110, 0.10);
  border-color: rgba(255, 200, 110, 0.30);
}
.sk-default-btn.is-on:disabled { cursor: default; opacity: 1; }

/* Inline "name this template" field that replaces the writer Add button. */
.sk-add-inline { display: inline-flex; align-items: center; gap: 8px; }
.sk-add-input {
  height: 32px;
  width: 220px;
  max-width: 48vw;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: #e8e8ea;
  font-size: 13px;
  font-family: inherit;
}
.sk-add-input:focus { outline: none; border-color: rgba(150, 230, 190, 0.4); }

/* Modal body guidance (chat/image): label row + helper paragraph. */
.sk-body-help { margin-bottom: 10px; }
.sk-body-help .sk-edit-help { margin: 3px 0 0; }

.sk-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.sk-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.sk-btn {
  height: 28px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: #e8e8ea;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.sk-btn:hover { background: rgba(255, 255, 255, 0.07); }
.sk-btn.danger:hover {
  color: #ffc4c4;
  border-color: rgba(255, 180, 180, 0.3);
}

/* The page modal reuses the shared .modal / .modal-card component in
   main.css; the body textarea is always shown here (unlike the
   composer's optional one). Skills — especially writer skills — can be
   long, so this modal gets a wider card and a much taller, scrollable
   editing area than the shared default. */
#sk-modal .modal-card {
  width: min(720px, 100%);
}
#sk-modal .modal-body {
  display: block;
  min-height: 320px;
  height: min(52vh, 560px);
  max-height: 70vh;
  resize: vertical;
}
.modal-save {
  height: 34px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(150, 230, 190, 0.10);
  color: #b8e6f5;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.modal-save:hover:not(:disabled) { background: rgba(150, 230, 190, 0.16); }
.modal-save:disabled { opacity: 0.5; cursor: default; }

/* The forced display:block above beats the [hidden] attribute, so a writer
   template (which hides the free-text body in favour of the structured
   fields) needs this explicit override. */
#sk-modal .modal-body[hidden] { display: none; }

/* Writer-template structured editor: labeled style levers + per-step model
   pickers. Shown only for kind='content'. */
.sk-fields { display: none; }
.sk-fields:not([hidden]) { display: flex; flex-direction: column; gap: 12px; }
.sk-field { display: flex; flex-direction: column; gap: 5px; }
.sk-field > span {
  font-size: 12px;
  color: #e8e8ea;
}
.sk-field-hint {
  font-weight: 400;
  color: var(--muted, #9aa0a6);
  font-size: 11px;
  margin-left: 6px;
}
/* Video-skill guardrail wrapper: same hidden/shown dance as .sk-fields so the
   [hidden] attribute isn't overridden by a display rule. */
.sk-video-avoid { display: none; margin-top: 12px; }
.sk-video-avoid:not([hidden]) { display: block; }
.sk-field textarea {
  min-height: 56px;
  max-height: 30vh;
  resize: vertical;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: #e8e8ea;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.45;
}
.sk-field textarea:focus { outline: none; border-color: rgba(150, 230, 190, 0.4); }

.sk-models {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sk-models-head { font-size: 13px; color: #e8e8ea; }
.sk-models-head span { color: var(--muted-2); font-size: 12px; }
.sk-model {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sk-model > span { font-size: 13px; color: var(--muted-2); }
.sk-model .chip-select { flex: 0 1 60%; }
.sk-model select {
  flex: 0 1 60%;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: #e8e8ea;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  /* Render the native dropdown popup in dark mode so the open option list
     isn't white-on-white. */
  color-scheme: dark;
}
.sk-model select:focus { outline: none; border-color: rgba(150, 230, 190, 0.4); }
/* Explicit fallback for browsers that ignore color-scheme on <option>. */
.sk-model select option {
  background: var(--panel-2);
  color: #e8e8ea;
}
.sk-model > span small {
  display: block;
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 11.5px;
  opacity: 0.8;
}

/* ── Dedicated writer-template editor (/skills/template/) ───────────── */
.sk-edit { padding: 18px 20px 20px; }

.sk-edit-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.sk-edit-name-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 320px;
  min-width: 0;
}
.sk-edit-name-label {
  font-size: 12px;
  color: var(--muted-2);
}
.sk-edit-headline {
  height: 40px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: #e8e8ea;
  font-size: 16px;
  font-weight: 500;
  font-family: inherit;
}
.sk-edit-headline:focus { outline: none; border-color: rgba(150, 230, 190, 0.4); }

.sk-edit-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sk-edit-status {
  font-size: 12px;
  color: var(--muted-2);
  min-width: 92px;
  text-align: right;
}
.sk-edit-status.is-saving { color: #ffe1a6; }
.sk-edit-status.is-saved { color: #b8e6f5; }
.sk-edit-status.is-dirty { color: var(--muted-2); }
.sk-edit-status.is-error { color: #ffc4c4; }

.sk-edit-default {
  height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: #e8e8ea;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.sk-edit-default:hover { background: rgba(255, 255, 255, 0.07); }
.sk-edit-default.is-on {
  color: #ffe1a6;
  background: rgba(255, 200, 110, 0.10);
  border-color: rgba(255, 200, 110, 0.30);
}

.sk-edit-section { padding-top: 20px; }
.sk-edit-section-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: #e8e8ea;
}
.sk-edit-section-sub {
  margin: 0 0 16px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted-2);
}

.sk-edit-field { margin-bottom: 18px; }
.sk-edit-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.sk-edit-fname {
  font-size: 13px;
  font-weight: 500;
  color: #e8e8ea;
}
.sk-edit-example {
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  font-size: 12px;
  color: #b8e6f5;
  cursor: pointer;
  white-space: nowrap;
}
.sk-edit-example:hover { text-decoration: underline; color: #d7f5ff; }
.sk-edit-help {
  margin: 3px 0 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted-2);
}
.sk-edit-field textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 56px;
  max-height: 30vh;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: #e8e8ea;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
}
.sk-edit-field textarea:focus { outline: none; border-color: rgba(150, 230, 190, 0.4); }

.sk-edit-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.sk-edit-footer .sk-btn { height: 34px; display: inline-flex; align-items: center; text-decoration: none; }
