/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.15s, background-color 0.15s;
}

.btn:hover {
  border-color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #091311;
  font-weight: 600;
}

.btn-primary:hover {
  filter: brightness(1.08);
  border-color: var(--accent);
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.btn-sm {
  min-height: 26px;
  padding: 3px 8px;
  font-size: 12px;
}

.btn-icon {
  min-width: 30px;
  padding: 5px;
}

/* Inputs & Selects */
.input,
.select,
.textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s;
}

.select-compact {
  width: auto;
  min-width: 135px;
  padding: 4px 8px;
  min-height: 30px;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--text-muted);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.textarea {
  resize: vertical;
  line-height: 1.45;
}

.textarea-mono {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  tab-size: 2;
}

/* Form Layout */
.field {
  margin-bottom: 10px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-inline {
  display: flex;
  gap: 6px;
  align-items: center;
}

@media (max-width: 600px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

/* Collapsible Sections */
.editor-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.editor-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.editor-section summary::-webkit-details-marker {
  display: none;
}

.editor-section summary::after {
  content: '▾';
  color: var(--text-muted);
  transition: transform 0.15s;
}

.editor-section:not([open]) summary::after {
  transform: rotate(-90deg);
}

.editor-section-body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* Tabs */
.tablist {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.tab-btn {
  position: relative;
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: var(--radius) var(--radius) 0 0;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn[aria-selected="true"] {
  color: var(--accent);
}

.tab-btn[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  border-block-end: 2px solid var(--accent);
}

.tab-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Wallpaper Preview */
.wallpaper-preview {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  background: var(--surface-raised);
  text-align: center;
}

.wallpaper-preview img {
  max-width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 4px;
}

/* Genre Tags */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
}

.tag-chip button {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
}

.tag-chip button:hover {
  color: var(--danger);
}

/* Screenshot Manager */
.shot-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.shot-card {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
}

.shot-thumb {
  width: 76px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
}

.shot-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shot-inputs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.shot-actions {
  display: flex;
  gap: 4px;
}

/* BBCode Output & Highlight */
.output-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}

.output-code {
  flex: 1;
  min-height: 320px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  margin: 0;
}

.bb-tag {
  color: var(--accent);
}

.bb-var {
  color: var(--accent-secondary);
  font-weight: 600;
}

.bb-url {
  color: #60a5fa;
}

/* Visual Preview */
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.preview-canvas {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-wrap: anywhere;
  min-height: 320px;
}

.preview-canvas.preview-dark {
  background: #111317;
  color: #e6e8ec;
}

.preview-canvas.preview-light {
  background: #ffffff;
  color: #172322;
}

.preview-canvas img {
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 4px;
}

.preview-canvas details.bb-spoiler {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px auto;
  text-align: left;
  background: rgba(128, 128, 128, 0.08);
}

.preview-canvas details.bb-spoiler summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}

.preview-canvas pre.bb-mediainfo,
.preview-canvas pre.bb-code {
  margin: 8px 0 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  text-align: left;
}

.preview-canvas blockquote.bb-quote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: rgba(128, 128, 128, 0.08);
  text-align: left;
}

/* Template Editor */
.code-editor-box {
  display: grid;
  grid-template-columns: 42px 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  min-height: 260px;
}

.line-numbers {
  padding: 8px 6px;
  background: var(--surface-raised);
  border-right: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  text-align: right;
  user-select: none;
  overflow: hidden;
}

.code-editor-box textarea {
  border: none;
  border-radius: 0;
  padding: 8px 10px;
  min-height: 260px;
  resize: vertical;
  background: transparent;
}

.code-editor-box textarea:focus {
  box-shadow: none;
}

/* Warnings & Status */
.banner {
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 12px;
  margin-bottom: 10px;
}

.banner-warn {
  border-color: color-mix(in srgb, var(--warning) 50%, transparent);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
}

.banner-danger {
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
  background: var(--surface-raised);
}

.pill-warn {
  border-color: var(--warning);
  color: var(--warning);
}

/* Dialogs */
dialog.modal {
  max-width: 680px;
  width: calc(100% - 24px);
  max-height: 88vh;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 15px;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(88vh - 110px);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  margin-bottom: 8px;
}

.list-item-main {
  min-width: 0;
  flex: 1;
}

.list-item-title {
  font-weight: 600;
  font-size: 13px;
}

.list-item-sub {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
