:root {
  color-scheme: light;
  --ink: #11120f;
  --paper: #f2f0e8;
  --white: #fffdf7;
  --coral: #ff5f3d;
  --lime: #c9f86a;
  --bg: var(--paper);
  --panel: var(--white);
  --panel-2: #fffdf7;
  --muted: rgba(17, 18, 15, 0.68);
  --line: rgba(17, 18, 15, 0.20);
  --accent: var(--coral);
  --accent-2: var(--lime);
  --danger: #b62619;
  --shadow: 0 12px 32px rgba(17, 18, 15, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  min-height: 34px;
  padding: 6px 10px;
}

button:hover {
  border-color: var(--ink);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
}

.left-nav {
  grid-row: 1 / -1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  min-height: 100vh;
  background: var(--ink);
  color: var(--white);
  border-right: 1px solid var(--ink);
}

.nav-brand {
  padding: 18px 16px 6px;
}

.left-nav .brand-mark {
  background: var(--lime);
  color: var(--ink);
}

.nav-list {
  display: grid;
  align-content: start;
  gap: 2px;
}

.nav-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  width: 100%;
  padding: 10px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 253, 247, 0.74);
  text-align: left;
  font-size: 16px;
  font-weight: 650;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(255, 253, 247, 0.10);
  color: var(--white);
}

.nav-item.is-active {
  box-shadow: inset 4px 0 0 var(--coral);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  font-size: 18px;
  line-height: 1;
}

.settings-item {
  align-self: end;
  min-height: 76px;
  margin-bottom: 0;
}

.topbar {
  grid-column: 2;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--white);
  font-weight: 800;
}

.top-actions,
.formatbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-action {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--white);
  font-weight: 750;
}

.primary-action:hover {
  border-color: var(--coral);
  background: var(--coral);
}

.workspace {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 500px);
  gap: 14px;
  padding: 14px;
  height: calc(100vh - 56px);
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.workspace.preview-hidden {
  grid-template-columns: minmax(420px, 1fr);
}

.workspace.preview-hidden .preview-pane {
  display: none;
}

.editor-pane,
.preview-pane {
  min-width: 0;
}

.editor-pane {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  min-height: 0;
}

.formatbar {
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.formatbar select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 6px 8px;
}

.format-spacer {
  flex: 1 1 auto;
}

.icon-button {
  min-width: 34px;
  padding: 6px 8px;
}

.emoji-panel {
  display: inline-flex;
  gap: 4px;
  padding-left: 4px;
}

.emoji-panel button {
  min-width: 34px;
  padding: 6px 7px;
}

.attachment-name {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.underline {
  text-decoration: underline;
}

.strike {
  text-decoration: line-through;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel);
}

.segmented button {
  border: 0;
  border-radius: 0;
  min-height: 32px;
}

.segmented .is-active {
  background: var(--lime);
  color: var(--ink);
  font-weight: 650;
}

.editor {
  min-height: 560px;
  overflow: auto;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  white-space: pre-wrap;
  font-size: 17px;
  line-height: 1.55;
}

.editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 95, 61, 0.16);
}

.editor:empty::before {
  content: "Write a LinkedIn post...";
  color: var(--muted);
}

.preview-pane {
  display: grid;
  justify-items: center;
  align-content: start;
}

.linkedin-card {
  width: 100%;
  max-width: 500px;
  background: #ffffff;
  color: #191919;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px 14px 8px;
  transition: max-width 160ms ease, background 160ms ease, color 160ms ease;
}

.linkedin-card.mobile {
  max-width: 360px;
}

.linkedin-card.dark {
  background: #171717;
  color: #f4f4f4;
  border-color: #333333;
}

.profile-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #0a66c2;
  color: #ffffff;
  font-weight: 750;
}

.avatar.has-image {
  background-position: center;
  background-size: cover;
  color: transparent;
}

.name-line {
  font-weight: 700;
}

.meta-line {
  color: #737373;
  font-size: 12px;
}

.dark .meta-line {
  color: #b5b5b5;
}

.preview-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.42;
  min-height: 120px;
}

.preview-body.collapsed {
  max-height: 112px;
  overflow: hidden;
}

.more-toggle {
  display: none;
  border: 0;
  background: transparent;
  color: #666666;
  padding: 4px 0;
  min-height: 24px;
}

.more-toggle.visible {
  display: inline-block;
}

.metrics-row,
.engagement-row {
  display: grid;
  grid-auto-flow: column;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #e5e5e5;
  margin-top: 10px;
  padding-top: 8px;
  color: #666666;
}

.dark .metrics-row,
.dark .engagement-row {
  border-top-color: #333333;
  color: #c8c8c8;
}

.engagement-row button {
  border: 0;
  background: transparent;
  color: inherit;
  min-height: 30px;
  padding: 4px 6px;
}

.template-meta {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  gap: 10px;
  color: var(--muted);
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.drafts-view,
.insights-view,
.settings-view {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  padding: 18px;
  overflow: auto;
}

.drafts-card,
.settings-card {
  min-height: calc(100vh - 92px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.drafts-head {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}

.drafts-head h1,
.settings-card h1 {
  margin: 0;
  font-size: 22px;
}

.draft-filters {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 16px 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.draft-filters label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

input,
.draft-filters select {
  min-height: 36px;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--white);
  padding: 6px 10px;
  color: var(--ink);
  font: inherit;
}

.draft-table-wrap {
  overflow: auto;
}

.draft-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

.draft-table th,
.draft-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.draft-table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.draft-number {
  width: 42px;
  color: var(--accent);
  font-weight: 700;
}

.draft-title-cell {
  min-width: 220px;
  max-width: 340px;
  font-size: 16px;
  font-weight: 650;
}

.draft-text-cell {
  min-width: 360px;
  max-width: 620px;
  overflow-wrap: anywhere;
}

.draft-status {
  color: var(--coral);
  font-weight: 700;
}

.draft-actions {
  display: flex;
  gap: 8px;
}

.draft-empty {
  padding: 20px;
  color: var(--muted);
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}

.insights-view {
  display: grid;
  align-content: start;
  gap: 16px;
}

.insights-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  background: var(--ink);
  color: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.insights-hero h1 {
  max-width: 780px;
  margin: 0 0 8px;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0;
}

.insights-hero p {
  max-width: 760px;
  margin: 0;
  color: rgba(255, 253, 247, 0.76);
  font-size: 16px;
}

.insights-kicker {
  margin: 0 0 8px !important;
  color: var(--lime) !important;
  font-size: 13px !important;
  font-weight: 800;
  text-transform: uppercase;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.insight-card {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 230px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(17, 18, 15, 0.08);
}

.insight-topline {
  justify-self: start;
  padding: 5px 8px;
  background: var(--lime);
  color: var(--ink);
  border-radius: 5px;
  font-weight: 850;
}

.insight-card h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
}

.insight-card p {
  margin: 0;
  color: var(--muted);
}

.insight-card a {
  align-self: end;
  justify-self: start;
  color: var(--ink);
  font-weight: 800;
  text-decoration-color: var(--coral);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.settings-card {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 22px;
}

.oauth-box,
.linkedin-profile-card {
  display: flex;
  gap: 16px;
  max-width: 760px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.oauth-box {
  align-items: center;
  justify-content: space-between;
}

.oauth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.oauth-box h2 {
  margin: 0 0 4px;
  font-size: 17px;
}

.oauth-box p {
  margin: 0;
  color: var(--muted);
}

.linkedin-profile-card {
  align-items: center;
  background: var(--white);
  max-width: 620px;
  padding: 14px;
}

.linkedin-profile-picture {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  object-fit: cover;
  background: var(--panel);
}

.linkedin-profile-copy {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.linkedin-profile-name {
  font-size: 22px;
  line-height: 1.15;
  font-weight: 500;
  color: var(--ink);
}

.linkedin-profile-email {
  font-size: 19px;
  line-height: 1.15;
  font-weight: 750;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.linkedin-profile-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  color: var(--muted);
  font-size: 16px;
}

.linkedin-profile-meta span + span {
  padding-left: 20px;
  border-left: 1px solid var(--line);
  color: var(--ink);
}

.bug-report-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 45;
  border-color: transparent;
  background: var(--ink);
  color: var(--coral);
  box-shadow: var(--shadow);
}

.feedback-form {
  position: fixed;
  right: 18px;
  bottom: 64px;
  z-index: 45;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 36px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.feedback-form textarea {
  width: 100%;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: 10px;
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: var(--ink);
  color: var(--white);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 50;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 196px minmax(0, 1fr);
  }

  .workspace {
    grid-template-columns: minmax(320px, 1fr) minmax(320px, 460px);
    height: auto;
    overflow: visible;
  }

}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .left-nav {
    grid-row: auto;
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .nav-brand {
    padding: 12px 14px 4px;
  }

  .nav-list {
    grid-auto-flow: column;
    grid-template-columns: 1fr 1fr;
  }

  .nav-item {
    min-height: 48px;
    font-size: 14px;
  }

  .settings-item {
    min-height: 48px;
  }

  .topbar {
    grid-column: 1;
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    grid-column: 1;
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .drafts-view,
  .insights-view,
  .settings-view {
    grid-column: 1;
  }

  .nav-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .insights-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .insights-hero h1 {
    font-size: 28px;
  }

  .editor {
    min-height: 420px;
  }

  .preview-pane {
    display: none;
  }

  .preview-pane.is-visible {
    display: grid;
  }

  .linkedin-profile-card {
    align-items: flex-start;
  }

  .linkedin-profile-picture {
    width: 56px;
    height: 56px;
    border-radius: 18px;
  }

  .linkedin-profile-name {
    font-size: 22px;
  }

  .linkedin-profile-email,
  .linkedin-profile-meta {
    font-size: 16px;
  }
}
