:root {
  --lime-green: #BEE034;
  --ocean-teal: #6FCDB6;
  --near-black: #26272B;
  --grey-100: #F5F5F5;
  --grey-200: #E5E5E5;
  --grey-500: #A0A0A0;
  --radius: 6px;
  --font-stack: "Galano Grotesque", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #fff;
  color: var(--near-black);
  font-family: var(--font-stack);
  font-size: 14px;
  line-height: 1.45;
}

#app {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}

.update-banner {
  background: linear-gradient(90deg, var(--lime-green), var(--ocean-teal));
  color: var(--near-black);
  padding: 10px 12px;
  border-radius: var(--radius);
  margin: 0 0 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.update-banner-text {
  flex: 1 1 100%;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}
.update-banner button {
  background: var(--near-black);
  color: white;
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  flex: 0 0 auto;
}
.update-banner button.ghost {
  background: rgba(0, 0, 0, 0.08);
  color: var(--near-black);
  padding: 6px 10px;
  font-weight: 700;
}
.update-banner button.ghost:hover {
  background: rgba(0, 0, 0, 0.16);
}

header {
  margin-bottom: 16px;
}
.logo {
  display: inline-block;
  background: var(--lime-green);
  color: var(--near-black);
  font-weight: 700;
  font-size: 13px;
  padding: 2px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
}
h1 {
  font-size: 22px;
  margin: 8px 0 4px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.lede {
  color: #555;
  margin: 0;
}

form { display: flex; flex-direction: column; gap: 12px; }
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #444;
  font-weight: 500;
}
input, textarea, select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  background: #fff;
  color: var(--near-black);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ocean-teal);
  box-shadow: 0 0 0 3px rgba(111, 205, 182, 0.25);
}
textarea { resize: vertical; }

.row { display: flex; gap: 12px; }
.grow { flex: 1; }

.check { flex-direction: row; align-items: center; gap: 8px; }
.check input { width: auto; }

.hint { font-weight: 400; color: #888; font-size: 11px; }

.file-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--grey-100);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 12px;
}
.file-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.file-list .size { color: #888; margin: 0 8px; }
.file-list .remove {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
  line-height: 1;
}
.file-list .remove:hover { color: #b00020; }
.file-list .skipped { color: #b08000; font-style: italic; }

button {
  font: inherit;
  font-weight: 700;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--lime-green);
  color: var(--near-black);
  cursor: pointer;
  transition: filter 0.15s;
}
button:hover { filter: brightness(0.95); }
button:disabled { opacity: 0.6; cursor: progress; }

.progress {
  height: 4px;
  background: var(--grey-200);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 4px;
  position: relative;
}
.progress .progress-bar {
  position: absolute;
  height: 100%;
  width: 33%;
  background: linear-gradient(90deg, var(--lime-green), var(--ocean-teal));
  border-radius: 999px;
  animation: lime-indeterminate 1.4s ease-in-out infinite;
}
@keyframes lime-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

.status {
  margin: 4px 0 0;
  min-height: 1.4em;
  font-size: 13px;
  color: #555;
}
.status.error { color: #b00020; }
.status.success { color: #1a7f37; }

.divider {
  border: none;
  border-top: 1px solid var(--grey-200);
  margin: 24px 0 16px;
}

/* When a deck has been generated, the refine UI takes the foreground.
   The generate form is hidden but reachable via the "start a new deck" link. */
body.deck-generated #form,
body.deck-generated #generate-lede,
body.deck-generated #divider {
  display: none;
}
body:not(.deck-generated) #refine-lede {
  display: none;
}
body:not(.deck-generated) #refine-section,
body:not(.deck-generated) #divider {
  display: none;
}

#restart-link { color: var(--ocean-teal); font-weight: 600; }

#refine-section h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
}

.banner {
  background: var(--grey-100);
  color: #666;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  margin: 8px 0 0;
}

.target-info {
  font-size: 12px;
  color: #555;
  margin: 0 0 4px;
  background: var(--grey-100);
  padding: 6px 10px;
  border-radius: var(--radius);
}
.target-info.has-target { color: var(--near-black); }
.target-info strong { color: var(--near-black); }

#refine-form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

footer {
  margin-top: 24px;
  color: var(--grey-500);
  text-align: center;
}
footer a { color: inherit; }

dialog {
  border: none;
  border-radius: 8px;
  padding: 16px;
  max-width: 90vw;
  max-height: 80vh;
}
dialog pre {
  background: var(--grey-100);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 11px;
  max-height: 50vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Manage dialog: a wider modal with two tabs (Templates / Brand voice). */
.manage-dialog {
  width: min(640px, 92vw);
  max-height: 85vh;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.manage-dialog::backdrop { background: rgba(0,0,0,0.35); }
.manage-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--grey-200);
}
.manage-header h2 { margin: 0; font-size: 16px; font-weight: 700; }
.manage-dialog .tabs {
  display: flex;
  border-bottom: 1px solid var(--grey-200);
  padding: 0 16px;
}
.manage-dialog .tab {
  background: none;
  border: none;
  padding: 10px 14px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  font-weight: 500;
}
.manage-dialog .tab.active { color: var(--near-black); border-bottom-color: var(--lime-green); }
.manage-dialog .tab-pane {
  display: none;
  padding: 14px 16px;
  overflow-y: auto;
}
.manage-dialog .tab-pane.active { display: block; }

button.ghost {
  background: var(--grey-100);
  color: var(--near-black);
  font-weight: 500;
}
button.ghost:hover { background: var(--grey-200); }

.manage-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.manage-list li {
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.manage-list .row1 {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.manage-list .name { font-weight: 600; }
.manage-list .meta { font-size: 11px; color: #888; }
.manage-list .desc { font-size: 12px; color: #444; margin: 4px 0 0; }
.manage-list .actions { display: flex; gap: 6px; }
.manage-list .edit,
.manage-list .delete {
  background: none;
  border: 1px solid var(--grey-200);
  padding: 4px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
}
.manage-list .edit { color: var(--near-black); }
.manage-list .edit:hover { background: var(--grey-100); }
.manage-list .delete { color: #b00020; }
.manage-list .delete:hover { background: #fdf0f3; }

.edit-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.edit-form .row { display: flex; gap: 8px; }
.edit-form .row > * { flex: 1; }
.edit-form .save { background: var(--lime-green); }
.edit-form .cancel { background: var(--grey-100); color: var(--near-black); font-weight: 500; }

#add-template-details summary {
  cursor: pointer;
  padding: 8px 12px;
  background: var(--grey-100);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
}
#add-template-details[open] summary { margin-bottom: 12px; }
#add-template-form { display: flex; flex-direction: column; gap: 10px; }

#brand-prompt-text {
  width: 100%;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
}

/* Done-panel step list on the browser landing page. */
.steps {
  margin: 8px 0;
  padding-left: 20px;
}
.steps li {
  margin: 4px 0;
  line-height: 1.45;
}
#no-addin-hint {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--grey-200);
}

/* ============================================================
   Web app (browser landing page). Scoped under .webapp so none
   of this affects the Office task pane.
   ============================================================ */
body.webapp { background: var(--grey-100); }
.wa-shell { max-width: 880px; margin: 0 auto; padding: 24px 20px 56px; }
/* Form controls placed directly in a card (not inside a flex label) still fill
   the width - notably the tone-of-voice editor. */
.wa-card > textarea, .wa-card > input, .wa-card > select { width: 100%; }
.wa-header { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.wa-header h1 { margin: 0; font-size: 26px; }
.wa-sub { margin: 2px 0 0; color: #666; font-size: 13px; }

.wa-tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--grey-200); margin: 16px 0 20px; }
.wa-tab {
  background: none; border: none; border-radius: 0;
  padding: 10px 18px; font-size: 14px; font-weight: 600; color: #777;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.wa-tab:hover { color: var(--near-black); }
.wa-tab.active { color: var(--near-black); border-bottom-color: var(--lime-green); }

.wa-pane { display: none; }
.wa-pane.active { display: block; }

.wa-card {
  background: #fff; border: 1px solid var(--grey-200); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.wa-h3 { margin: 0 0 12px; font-size: 15px; }
.wa-pane > .lede { margin: 0 0 16px; color: #555; }

/* Category folders + template cards */
.folders { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.folder {
  background: var(--grey-100); border: 1px solid var(--grey-200); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--near-black); cursor: pointer;
}
.folder:hover { border-color: #bbb; }
.folder.active { background: var(--lime-green); border-color: var(--lime-green); }

.tpl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.tpl-card {
  text-align: left; background: #fff; border: 1px solid var(--grey-200); border-radius: var(--radius);
  padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.tpl-card:hover { border-color: #aaa; }
.tpl-card.selected { border-color: var(--lime-green); box-shadow: inset 0 0 0 2px var(--lime-green); }
.tpl-title { font-weight: 700; }
.tpl-meta { font-size: 11px; color: #888; }
.tpl-desc { font-size: 12px; color: #555; }

/* Category headers in the admin template list */
.manage-list .cat-head {
  border: none; background: none; padding: 12px 0 2px; margin: 0;
  font-weight: 700; font-size: 13px; color: #555;
}
.manage-list .cat-head:first-child { padding-top: 0; }

@media (max-width: 620px) {
  .wa-shell { padding: 16px 12px 40px; }
  .tpl-cards { grid-template-columns: 1fr; }
}

/* Admin sub-tabs (Templates / Tone of voice). The .tab/.tab-pane rules above
   are scoped to .manage-dialog, so the web page needs its own copy - without
   this, inactive panes never hide and clicking a tab does nothing visible. */
#wtab-admin .tabs {
  display: flex; gap: 2px;
  border-bottom: 2px solid var(--grey-200);
  margin: 0 0 16px;
}
#wtab-admin .tab {
  background: none; border: none; border-radius: 0;
  padding: 9px 16px; font-size: 14px; font-weight: 600; color: #777;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
#wtab-admin .tab:hover { color: var(--near-black); }
#wtab-admin .tab.active { color: var(--near-black); border-bottom-color: var(--lime-green); }
#wtab-admin .tab-pane { display: none; }
#wtab-admin .tab-pane.active { display: block; }

/* Category chips in the admin Categories manager */
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--grey-100); border: 1px solid var(--grey-200); border-radius: 999px;
  padding: 5px 10px; font-size: 13px; font-weight: 600;
}
.cat-chip.in-use { opacity: 0.8; }
.cat-x {
  background: none; border: none; cursor: pointer; font-size: 15px; line-height: 1;
  color: #b00020; padding: 0 0 0 2px; font-weight: 700;
}
.cat-x:hover { color: #7a0016; }
#admin-cat-form { align-items: flex-end; margin-top: 4px; }

/* "How it works" instructions block on the Create tab */
.how-to > summary {
  cursor: pointer; font-weight: 700; font-size: 15px; list-style: none;
}
.how-to > summary::-webkit-details-marker { display: none; }
.how-to > summary::before { content: "\25B8  "; color: var(--grey-500); }
.how-to[open] > summary::before { content: "\25BE  "; }
.how-to .how-steps { margin: 12px 0 4px; padding-left: 20px; }
.how-to .how-steps li { margin: 6px 0; line-height: 1.45; }

/* Admin Templates tab: categories (left) + templates (right) */
.admin-tpl-layout { display: flex; gap: 16px; align-items: flex-start; }
.admin-tpl-layout .admin-cats { flex: 0 0 250px; margin-bottom: 0; }
.admin-tpl-layout .admin-tpls { flex: 1 1 auto; min-width: 0; margin-bottom: 0; }

.cat-rows { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cat-row {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px; border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer; font-size: 13px; background: var(--grey-100);
}
.cat-row:hover { border-color: var(--grey-200); }
.cat-row.selected { background: var(--lime-green); font-weight: 700; }
.cat-row.all { background: #fff; border: 1px dashed var(--grey-200); }
.cat-row.all.selected { background: var(--lime-green); border-style: solid; }
.cat-row.dragging { opacity: 0.45; }
.cat-row.drop-target { border-color: var(--ocean-teal); box-shadow: inset 0 2px 0 var(--ocean-teal); }
.cat-grip { color: var(--grey-500); cursor: grab; letter-spacing: -2px; font-size: 12px; }
.cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count {
  background: rgba(0,0,0,0.08); border-radius: 999px;
  padding: 1px 7px; font-size: 11px; font-weight: 600;
}
.cat-add { display: flex; gap: 6px; }
.cat-add input { flex: 1; min-width: 0; }
.cat-add button { padding: 8px 12px; }

@media (max-width: 760px) {
  .admin-tpl-layout { flex-direction: column; }
  .admin-tpl-layout .admin-cats { flex: 1 1 auto; width: 100%; }
}

/* Admin > Master template: the current master's facts, as label/value pairs. */
.master-info {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 12px 0 16px;
  font-size: 13px;
}
.master-info dt {
  color: #888;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: center;
}
.master-info dd {
  margin: 0;
  color: #222;
}
.master-info dd.error { color: #b00020; }
.master-info dd.meta { color: #888; }

/* The "use it anyway" opt-in, only shown when the upload has a fixable fault. */
.checkline {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
  color: #444;
}
.checkline input { margin-top: 2px; }

/* Admin > Icons: a browsable grid, since curating means recognising graphics. */
.icon-grid {
  list-style: none;
  padding: 0;
  margin: 12px 0 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.icon-tile {
  border: 1px solid var(--grey-200);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.icon-tile img,
.icon-tile .icon-missing {
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.icon-tile .icon-missing {
  border: 1px dashed var(--grey-200);
  border-radius: 6px;
}
.icon-tile .icon-name {
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.icon-tile .meta { font-size: 11px; color: #888; }
/* Retired icons stay visible but read as switched off. */
.icon-tile.retired { opacity: 0.55; background: #fafafa; }
.icon-tile.editing { align-items: stretch; text-align: left; }
.icon-tile.editing input {
  width: 100%;
  font-size: 12px;
  padding: 4px 6px;
  margin: 0;
}
.icon-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; }
.icon-actions button {
  font-size: 11px;
  padding: 3px 8px;
  background: none;
  border: 1px solid var(--grey-200);
  border-radius: 999px;
  cursor: pointer;
  color: var(--near-black);
}
.icon-actions button:hover { border-color: var(--near-black); }
