/* =============================================================
   PowerPoint Table Style Editor — tool-specific styles
   Built on the shared design system (styles.css); uses its CSS
   variables so the tool follows the site's light/dark theme.
   All rules are scoped under .pste.
   ============================================================= */

/* [hidden] must beat display:flex/grid on tool containers.
   The browser's UA stylesheet sets [hidden]{display:none} but author
   styles with any class selector win — so we re-declare it here. */
[hidden] { display: none !important; }

/* ---- Top action bar (shown after file load) ---- */
.pste-top-actions {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.pste-file-chip {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  color: var(--text-soft);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pste-top-actions button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  transition: border-color .15s, background .15s;
}
.pste-top-actions button:hover { border-color: var(--brand); background: var(--bg-soft); }
.pste-top-actions .pste-download-btn {
  background: var(--brand-grad);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow);
  margin-left: auto;
}
.pste-top-actions .pste-download-btn:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }

/* ---- Upload stage ---- */
.pste .pste-upload-stage {
  padding: 40px 24px;
}
.pste .pste-dropzone {
  display: block;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 52px 36px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-elev);
  transition: border-color .15s, background .15s, transform .15s;
}
.pste .pste-dropzone:hover,
.pste .pste-dropzone.drag {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 6%, var(--bg-elev));
  transform: translateY(-2px);
}
.pste .pste-dropzone h2 { font-size: 20px; margin: 0 0 8px; color: var(--text); }
.pste .pste-dropzone .hl { color: var(--brand); }
.pste .pste-dropzone p { color: var(--text-soft); margin: 8px 0 0; font-size: 14px; }
.pste .pste-dz-note { display: inline-block; margin-top: 14px; color: var(--text-soft); font-size: 12px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }
.pste .pste-dropzone input { display: none; }
.pste .pste-upload-err { color: var(--office-powerpoint); font-size: 14px; font-weight: 600;
  margin-top: 14px; text-align: center; }

/* ---- Workspace layout ---- */
.pste-workspace {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 70vh;
  border-top: 1px solid var(--border);
}
@media (max-width: 820px) {
  .pste-workspace { grid-template-columns: 1fr; }
}

/* ---- Sidebar ---- */
.pste-sidebar {
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pste-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pste-sidebar-head h2 { font-size: 16px; margin: 0; color: var(--text); }
.pste-add-style-btn {
  font: inherit; font-size: 13px; font-weight: 600;
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text); padding: 6px 10px; border-radius: 8px; cursor: pointer;
  white-space: nowrap;
}
.pste-add-style-btn:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--bg-elev)); }
.pste-found-note {
  font-size: 12px; color: var(--text-soft);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
}
.pste-style-list {
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px;
}
.pste-style-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; cursor: pointer; transition: border-color .13s; position: relative;
}
.pste-style-card:hover { border-color: var(--text-soft); }
.pste-style-card.active { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.pste-style-card .name { font-weight: 600; font-size: 14px; display: block; padding-right: 20px;
  color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pste-style-card .id { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 10px; color: var(--text-soft); display: block; margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pste-style-card .badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--office-excel); border: 1px solid var(--office-excel); border-radius: 5px;
  padding: 1px 5px; margin-top: 6px; display: inline-block;
}
.pste-style-card .card-del {
  position: absolute; top: 8px; right: 8px;
  border: none; background: none; cursor: pointer;
  color: var(--text-soft); font-size: 14px; line-height: 1; padding: 3px 5px; border-radius: 5px;
}
.pste-style-card .card-del:hover { color: var(--office-powerpoint); background: color-mix(in srgb, var(--office-powerpoint) 12%, transparent); }

/* ---- Editor panel ---- */
.pste-editor {
  padding: 24px 28px;
  overflow: auto;
  background: var(--bg-elev);
}
.pste-editor-empty { color: var(--text-soft); text-align: center; margin-top: 15vh; font-size: 15px; }
.pste-editor-head {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.pste-editor-head .pste-field { flex: 1; min-width: 220px; }
.pste-field { display: flex; flex-direction: column; gap: 5px; }
.pste-field-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft); }
.pste-field input[type=text] { width: 100%; }
.pste-id-line { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 10px; color: var(--text-soft); margin-top: 4px; display: block; }
.pste-default-toggle {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
  cursor: pointer;
}
.pste-default-toggle input { width: auto; accent-color: var(--brand); }

/* Shared input/select styles */
.pste select, .pste input[type=text], .pste input[type=number] {
  font: inherit; background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 8px;
}
.pste select { width: auto; max-width: 100%; }
.pste select:focus, .pste input[type=text]:focus, .pste input[type=number]:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
}

/* ---- Live preview ---- */
.pste-preview-wrap { margin-bottom: 22px; }
.pste-preview-wrap .pste-field-label { display: block; margin-bottom: 8px; }
.pste-tbl-preview {
  border-collapse: collapse; width: 100%; max-width: 520px;
  font-size: 13px; background: #fff; border-radius: 6px; overflow: hidden;
  box-shadow: var(--shadow);
}
.pste-tbl-preview td { padding: 7px 10px; border: 1px solid transparent; }

/* ---- Parts accordion ---- */
.pste-parts { display: flex; flex-direction: column; gap: 8px; }
.pste-part {
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-soft); overflow: hidden;
}
.pste-part > summary {
  list-style: none; cursor: pointer; padding: 11px 14px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.pste-part > summary::-webkit-details-marker { display: none; }
.pste-part > summary .chev { color: var(--text-soft); transition: transform .15s; }
.pste-part[open] > summary .chev { transform: rotate(90deg); }
.pste-part > summary:hover { background: var(--bg); }
.pste-part-body {
  padding: 8px 14px 16px; border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px;
}
.pste-ctl { display: flex; flex-direction: column; gap: 5px; }
.pste-sub { font-size: 10.5px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }

/* ---- Colour controls ---- */
.pste-color { display: flex; flex-direction: column; gap: 6px; }
.pste-color-top { display: flex; gap: 7px; }
.pste-picker { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pste-scheme-grid { display: flex; flex-wrap: wrap; gap: 5px; max-width: 256px; }
.pste-scheme-swatch {
  width: 22px; height: 22px; padding: 0; border-radius: 6px; cursor: pointer;
  border: 1px solid rgba(0,0,0,.22);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
  transition: transform .08s;
}
.pste-scheme-swatch:hover { transform: scale(1.12); }
.pste-scheme-swatch.active { outline: 2px solid var(--brand); outline-offset: 1px; }
.pste-hexfield-wrap { display: flex; align-items: center; gap: 6px; }
.pste-hexfield-wrap input[type=color] {
  width: 36px; height: 32px; padding: 0; border: 1px solid var(--border);
  border-radius: 7px; cursor: pointer; background: none;
}
.pste-hexfield {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 7px; padding: 0 8px;
}
.pste-hexfield .hexhash { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--text-soft); }
.pste-hexfield input[type=text] {
  width: 70px; border: none; background: none; padding: 6px 0;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; text-transform: uppercase;
  box-shadow: none;
}
.pste-hexfield input[type=text]:focus { box-shadow: none; }

/* ---- Font control ---- */
.pste-font { display: flex; flex-direction: column; gap: 6px; }
.pste-font-named input { width: 100%; box-sizing: border-box; }

/* ---- Presentation-wide options panel ---- */
.pste-global-panel { margin: 18px 0 6px; }
.pste-global {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-soft); overflow: hidden;
}
.pste-global > summary {
  list-style: none; cursor: pointer; padding: 12px 16px;
  font-weight: 600; font-size: 14px; color: var(--text);
}
.pste-global > summary::-webkit-details-marker { display: none; }
.pste-global > summary::before {
  content: "▸"; color: var(--text-soft); display: inline-block;
  margin-right: 8px; transition: transform .15s;
}
.pste-global[open] > summary::before { transform: rotate(90deg); }
.pste-global > summary:hover { background: var(--bg); }
.pste-global-body { padding: 4px 16px 16px; border-top: 1px solid var(--border); }
.pste-tts-toggle {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  font-size: 14px; margin: 12px 0; font-weight: 600;
}
.pste-tts-toggle input { width: 16px; height: 16px; cursor: pointer; }
.pste-tts-row { display: flex; align-items: center; gap: 8px; margin: 0 0 14px 25px; flex-wrap: wrap; }
.pste-tts-row input[type=number] {
  width: 92px; padding: 7px 9px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-elev); color: var(--text); font: inherit;
}
.pste-tts-unit { color: var(--text-soft); font-size: 13px; }
.pste-tts-cur { color: var(--text-soft); font-size: 12px; margin-left: 8px; }
.pste-tts-note {
  font-size: 12.5px; color: var(--text-soft); line-height: 1.55;
  border-left: 3px solid var(--border); padding: 2px 0 2px 12px; margin-top: 6px;
}
.pste-tts-note p { margin: 0 0 6px; }
.pste-tts-note ul { margin: 0; padding-left: 18px; }
.pste-tts-note li { margin: 3px 0; }
.pste-tts-note strong { color: var(--text); }

/* ---- Borders ---- */
.pste-borders { grid-column: 1 / -1; border-top: 1px dashed var(--border); padding-top: 12px; }
.pste-borders > .pste-sub { display: block; margin-bottom: 10px; }
.pste-bsides {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px;
}
.pste-bside {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
.pste-bside .nm { width: 60px; font-size: 12px; font-weight: 600; color: var(--text-soft); }
.pste-bside input[type=number] { width: 60px; font-size: 12px; }
.pste-bside .mini-color { display: flex; align-items: center; }
.pste-bside input[type=color] {
  width: 28px; height: 26px; padding: 0; border: 1px solid var(--border);
  border-radius: 5px; cursor: pointer; background: none;
}
.pste-bside input[type=checkbox] { width: auto; accent-color: var(--brand); cursor: pointer; }

/* ---- Modal ---- */
.pste-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.pste-modal {
  background: var(--bg-elev); border-radius: var(--radius); padding: 28px;
  width: min(620px, 94vw); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 16px;
  max-height: 90vh; overflow: auto;
}
.pste-modal h2 { font-size: 20px; margin: 0; color: var(--text); }
.pste-base-choice { border: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.pste-radio {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 13.5px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
}
.pste-radio input { margin-top: 3px; width: auto; accent-color: var(--brand); }
.pste-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.pste-modal-actions button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px;
  padding: 9px 16px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
  transition: border-color .15s;
}
.pste-modal-actions button:hover { border-color: var(--brand); }
.pste-modal-actions .pste-btn-primary {
  background: var(--brand-grad); color: #fff; border-color: transparent; box-shadow: var(--shadow);
}
.pste-modal-actions .pste-btn-primary:hover { box-shadow: var(--shadow-lg); }

/* ---- Built-in gallery ---- */
.pste-builtin-gallery {
  max-height: 44vh; overflow: auto;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
  background: var(--bg-soft);
  display: flex; flex-direction: column; gap: 4px;
}
.pste-gallery-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-soft); margin: 8px 2px 3px;
}
.pste-gallery-group-label:first-child { margin-top: 0; }
.pste-gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 7px;
  margin-bottom: 4px;
}
.pste-thumb-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 5px;
  cursor: pointer; padding: 7px 7px 8px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--bg-elev); font: inherit; color: var(--text);
  text-align: left;
}
.pste-thumb-card:hover { border-color: var(--text-soft); }
.pste-thumb-card.selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; }
.pste-thumb-wrap {
  display: flex; justify-content: center; align-items: center;
  background: #fff; border: 1px solid var(--border); border-radius: 5px;
  padding: 5px; min-height: 44px;
}
.pste-thumb-tbl { border-collapse: collapse; width: 80px; }
.pste-thumb-tbl td { height: 8px; border: 0.5px solid rgba(0,0,0,.07); }
.pste-thumb-label {
  font-size: 10px; line-height: 1.25; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft);
}

/* ---- Toast ---- */
.pste-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px;
  border-radius: 10px; font-size: 13px; z-index: 60; box-shadow: var(--shadow-lg);
  pointer-events: none;
}
.pste-toast.err { background: var(--office-powerpoint); }

/* ---- Footer caption ---- */
.pste .pste-caption {
  color: var(--text-soft); font-size: 12px; text-align: center; margin-top: 16px; padding-bottom: 32px;
}
