:root {
  --bg: #f4f5f2;
  --panel: #ffffff;
  --ink: #111312;
  --muted: #68706b;
  --line: #d9ded8;
  --green: #32d269;
  --green-dark: #13933d;
  --black: #000000;
  --gray-button: #7b837e;
  --shadow: 0 22px 70px rgba(17, 19, 18, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

body.auth-loading .site-shell,
body.auth-signed-out .site-shell {
  display: none;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea,
select {
  font: inherit;
}

.site-shell {
  min-height: 100vh;
  padding: 28px;
}

.auth-gate {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.auth-card {
  display: grid;
  width: min(100%, 420px);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.auth-message.error {
  color: #a22a2a;
}

.admin-session-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin: 0 auto 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 auto 16px;
}

.tab-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e8ece7;
  color: #232824;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.tab-button.active {
  border-color: var(--green);
  background: var(--green);
  color: #07110a;
}

.tab-button:disabled {
  border-color: #9ba39b;
  background: #7d867d;
  color: #e3e8e1;
  cursor: not-allowed;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
}

.tab-panel:not(.active) {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(420px, 1fr);
  gap: 28px;
  min-height: calc(100vh - 100px);
}

.controls-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.controls-panel {
  border-radius: 8px;
  padding: 28px;
  overflow: auto;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  min-width: 0;
  padding: 24px;
}

.panel-header,
.preview-toolbar {
  margin-bottom: 24px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.35rem);
}

h2 {
  font-size: 1.25rem;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.profile-picker-row {
  display: grid;
  gap: 8px;
}

.profile-picker-row .secondary-button {
  justify-self: start;
}

.selected-profile-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
}

.field {
  display: grid;
  gap: 7px;
}

.picture-replace-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.picture-replace-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 48px;
  padding: 0 16px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.file-upload-status {
  min-width: 0;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-upload-status.error {
  color: #a22a2a;
}

.file-upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.form-photo-preview {
  width: 72px;
  aspect-ratio: 1;
  border: 1px solid #cbd1ca;
  border-radius: 999px;
  background: #1c1f1d;
  object-fit: cover;
}

.form-photo-preview[hidden] {
  display: none;
}

.field span {
  color: #333835;
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #cbd1ca;
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--green-dark);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(50, 210, 105, 0.18);
}

.file-field input {
  padding: 10px;
}

.color-control {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
}

.color-control input[type="color"] {
  height: 45px;
  padding: 4px;
}

.wide {
  min-width: 0;
}

.action-row,
.download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.generate-button,
.secondary-button,
.tertiary-button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 17px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 160ms ease;
}

.generate-button {
  flex: 1;
  position: relative;
  display: inline-grid;
  place-items: center;
  background: var(--gray-button);
  color: #ffffff;
}

.generate-button.ready {
  background: var(--green);
  color: #07110a;
}

.secondary-button {
  background: #e8ece7;
  color: #1f2421;
}

.tertiary-button {
  background: #e8f1ff;
  color: #0757b8;
}

.tertiary-button:not(:disabled):active {
  transform: translateY(1px);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  padding: 0;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.generate-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.generate-button:not(:disabled):active,
.secondary-button:not(:disabled):active {
  transform: translateY(1px);
}

.generate-button.loading {
  color: transparent;
}

.generate-button.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.38);
  border-top-color: #ffffff;
  border-radius: 999px;
  animation: spin 760ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.preview-frame {
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-radius: 8px;
  background: #dce1dc;
  padding: 18px;
}

.reply-panel {
  grid-template-columns: minmax(340px, 500px) minmax(420px, 1fr);
  gap: 28px;
  min-height: calc(100vh - 100px);
}

.reply-v2-panel {
  grid-template-columns: minmax(360px, 520px) minmax(420px, 1fr);
  gap: 28px;
  min-height: calc(100vh - 100px);
}

.comment-generator-panel {
  grid-template-columns: minmax(360px, 520px) minmax(420px, 1fr);
  gap: 28px;
  min-height: calc(100vh - 100px);
}

.reply-input-panel {
  align-self: start;
}

.v2-directions {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}

.tutorial-button {
  justify-self: start;
}

.v2-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
  color: #303632;
  line-height: 1.42;
}

.reply-v2-results-panel {
  gap: 24px;
}

.comment-generator-results-panel {
  gap: 24px;
}

.comment-generator-post-preview {
  display: grid;
  gap: 8px;
}

.comment-generator-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #dfe5df;
  border-radius: 8px;
  background: #fbfcfb;
  padding: 14px 16px;
}

.comment-generator-loading p {
  margin: 0;
  color: #303632;
  font-weight: 760;
  line-height: 1.35;
}

.comment-generator-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(19, 147, 61, 0.2);
  border-top-color: var(--green-dark);
  border-radius: 999px;
  animation: spin 760ms linear infinite;
  flex: 0 0 auto;
}

.tutorial-dialog {
  width: min(920px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 0;
}

.tutorial-dialog::backdrop {
  background: rgba(17, 19, 18, 0.62);
}

.profile-dialog {
  width: min(920px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 0;
}

.profile-dialog::backdrop {
  background: rgba(17, 19, 18, 0.62);
}

.profile-modal {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.profile-dialog-view {
  display: grid;
  gap: 18px;
}

.profile-dialog-view[hidden] {
  display: none;
}

.profile-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.profile-modal-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.86fr) minmax(300px, 1fr);
  gap: 18px;
}

.profile-list-panel {
  display: grid;
  align-content: start;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  height: min(54vh, 430px);
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f6;
  padding: 12px;
}

.profile-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 4px 2px 2px;
}

.profile-new-button {
  width: 100%;
}

.profile-option {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: stretch;
}

.profile-option-main {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid #dfe5df;
  border-radius: 8px;
  background: #ffffff;
  color: #171b18;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.profile-option.active .profile-option-main {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(50, 210, 105, 0.16);
}

.profile-option-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-option-main span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-edit-button {
  min-height: auto;
  padding: 0 12px;
}

.profile-delete-button {
  display: inline-grid;
  background: #ffe8e8;
  color: #a22a2a;
  min-height: auto;
  width: 48px;
  padding: 0;
  place-items: center;
}

.profile-delete-button:hover {
  background: #ffd6d6;
}

.profile-delete-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.profile-form {
  display: grid;
  gap: 14px;
}

.profile-photo-field {
  display: grid;
  gap: 7px;
}

.profile-photo-label {
  color: #333835;
  font-size: 0.9rem;
  font-weight: 700;
}

.profile-photo-control {
  display: block;
}

.profile-photo-inputs {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.profile-current-photo-preview {
  width: 110px;
  aspect-ratio: 1;
  border: 1px solid #cbd1ca;
  border-radius: 999px;
  background: #1c1f1d;
  object-fit: cover;
}

.profile-current-photo-preview[hidden] {
  display: none;
}

.profile-crop-editor {
  display: grid;
  justify-items: center;
  gap: 16px;
}

.profile-crop-editor[hidden] {
  display: none;
}

.profile-crop-canvas {
  width: min(360px, 100%);
  aspect-ratio: 1;
  border: 1px solid #cbd1ca;
  border-radius: 999px;
  background: #1c1f1d;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.profile-crop-canvas.dragging {
  cursor: grabbing;
}

.profile-crop-control {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 10px;
  align-items: center;
  width: min(420px, 100%);
  color: #333835;
  font-size: 0.84rem;
  font-weight: 740;
}

.profile-crop-control input[type="range"] {
  width: 100%;
}

.profile-form-message,
.profile-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 740;
  line-height: 1.35;
}

.profile-form-message.error {
  color: #a22a2a;
}

.profile-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.profile-form-actions .generate-button {
  flex: 1;
}

.tutorial-modal {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.tutorial-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.tutorial-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  border: 0;
  background: #111312;
}

.linkedin-auth-card {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 16px;
}

.linkedin-auth-status,
.linkedin-auth-detail {
  margin: 0;
}

.linkedin-auth-status {
  color: #171b18;
  font-weight: 800;
  line-height: 1.25;
}

.linkedin-auth-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.linkedin-auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.reply-results-panel {
  gap: 24px;
}

.linkedin-post-preview {
  border-bottom: 1px solid var(--line);
  padding-bottom: 22px;
}

.loaded-post-text {
  margin: 0;
  color: #242925;
  font-size: 1.06rem;
  line-height: 1.55;
  white-space: pre-line;
}

.parsed-post-author {
  margin: 0 0 18px;
  color: #171b18;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.25;
}

.comments-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.comments-header h2 {
  font-size: 1.35rem;
}

.comments-summary {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
  line-height: 1.25;
  text-transform: uppercase;
}

.refresh-button {
  min-height: 38px;
  padding: 0 14px;
}

.generate-all-replies-button {
  min-height: 38px;
  padding: 0 14px;
  white-space: nowrap;
}

.comments-list {
  display: grid;
  gap: 12px;
}

.comment-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 16px;
}

.comment-card.has-reply {
  background: #eef1ee;
  color: #69716b;
}

.comment-body {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.comment-body h3 {
  margin: 0;
  color: #171b18;
  font-size: 1rem;
  line-height: 1.2;
}

.comment-card.has-reply h3 {
  color: #555d58;
}

.comment-body p {
  margin: 0;
  line-height: 1.45;
}

.comment-status {
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.comment-card.has-reply .comment-status {
  color: #818982;
}

.comment-reply-button {
  position: relative;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: #07110a;
  padding: 0 17px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 160ms ease;
  white-space: nowrap;
}

.comment-reply-button.generated {
  background: #e8ece7;
  color: #1f2421;
}

.comment-card.has-reply .comment-reply-button:not(.generated) {
  background: #bfe8c8;
  color: #155927;
}

.comment-reply-button:disabled {
  cursor: not-allowed;
  opacity: 0.78;
}

.comment-reply-button:not(:disabled):active {
  transform: translateY(1px);
}

.comment-reply-button.loading {
  color: transparent;
}

.comment-reply-button.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(7, 17, 10, 0.26);
  border-top-color: #07110a;
  border-radius: 999px;
  animation: spin 760ms linear infinite;
}

.generated-replies {
  display: grid;
  grid-column: 1 / -1;
  gap: 12px;
  border-top: 1px solid #dfe5df;
  padding-top: 16px;
}

.generated-replies-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.generated-reply-option {
  display: grid;
  gap: 7px;
  border: 1px solid #dfe5df;
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #ffffff;
  padding: 13px 14px 14px;
  box-shadow: 0 8px 18px rgba(24, 36, 28, 0.05);
}

.generated-reply-label {
  color: var(--green-dark);
  font-size: 0.73rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
}

.generated-reply-text {
  margin: 0;
  color: #171b18;
  font-size: 0.98rem;
  line-height: 1.52;
  white-space: pre-line;
}

.generated-replies-empty {
  margin: 0;
  color: var(--muted);
}

.post-artboard {
  --post-font-family: "Proxima Nova", Inter, Arial, sans-serif;
  --post-background: var(--black);
  --post-text-color: #ffffff;
  --title-color: var(--green);
  position: relative;
  width: min(100%, 820px);
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--post-background);
  color: var(--post-text-color);
  container-type: inline-size;
}

.profile-block {
  display: flex;
  align-items: center;
  gap: 2.9%;
  padding: 4.3% 3.1% 0;
}

.profile-photo {
  width: var(--avatar-size, 11.72cqw);
  aspect-ratio: 1;
  border-radius: 999px;
  object-fit: cover;
  background: #1c1f1d;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.profile-photo:not([src]) {
  visibility: hidden;
}

.profile-copy {
  min-width: 0;
}

.preview-name {
  color: var(--post-text-color);
  font-family: Inter, Arial, sans-serif;
  font-size: 3.95cqw;
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: 0;
  white-space: nowrap;
}

.preview-handle {
  margin-top: 12px;
  color: #888f89;
  font-family: Inter, Arial, sans-serif;
  font-size: 3.5417cqw;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.text-block {
  padding: 4.1% 3.1% 0;
}

.editable-title,
.insight-main,
.insight-subpoint {
  display: block;
  max-width: 100%;
  overflow: hidden;
  outline: none;
  text-overflow: clip;
}

.editable-title {
  min-height: 1.15em;
  color: var(--title-color);
  font-family: var(--post-font-family);
  font-size: 5.9896cqw;
  font-weight: 900;
  line-height: 1.16;
  letter-spacing: 0;
  white-space: normal;
}

.editable-title:empty::before {
  content: attr(data-placeholder);
  color: var(--title-color);
  opacity: 0.42;
}

.editable-lines {
  display: grid;
  gap: 3.4cqw;
  margin: 3.2% 0 0;
  padding: 0;
  list-style: none;
}

.insight-item {
  display: grid;
  gap: 0.6cqw;
  min-width: 0;
}

.insight-main,
.insight-subpoint {
  color: var(--post-text-color);
  font-family: var(--post-font-family);
  line-height: 1.08;
  letter-spacing: 0;
  white-space: nowrap;
}

.insight-main {
  font-size: clamp(20px, 3.8542cqw, 74px);
  font-weight: 900;
}

.insight-subpoints {
  display: grid;
  gap: 0.35cqw;
}

.insight-subpoint {
  font-size: clamp(20px, 3.75cqw, 72px);
  padding-left: 1.8cqw;
  font-weight: 500;
}

.insight-main:focus,
.insight-subpoint:focus,
.editable-title:focus {
  background: rgba(50, 210, 105, 0.12);
  box-shadow: 0 0 0 5px rgba(50, 210, 105, 0.12);
}

@media (max-width: 980px) {
  .site-shell {
    padding: 18px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .reply-panel {
    grid-template-columns: 1fr;
  }

  .reply-v2-panel {
    grid-template-columns: 1fr;
  }

  .comment-generator-panel {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    min-height: 72vh;
  }
}

@media (max-width: 620px) {
  .controls-panel,
  .preview-panel {
    padding: 18px;
  }

  .preview-toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .download-actions {
    width: 100%;
  }

  .download-actions button {
    flex: 1;
  }

  .tab-button {
    flex: 1;
  }

  .comments-header {
    align-items: stretch;
    flex-direction: column;
  }

  .generate-all-replies-button {
    width: 100%;
  }

  .comment-card {
    grid-template-columns: 1fr;
  }

  .comment-reply-button {
    width: 100%;
  }

  .profile-modal-grid {
    grid-template-columns: 1fr;
  }
}
