/* Charik Studio. Design tokens copied from the Charik CRM (charik-crm-design, src/index.css):
   light background only, navy rail, Charik blue for what is clickable, green-to-blue gradient for the main
   action, brown (amber) for destructive and exit actions, never red for an action. */
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/fonts/inter.woff2") format("woff2-variations");
}

:root {
  --bg: #F3F6FA; --surface: #FFFFFF; --surface-2: #F6F8FB; --surface-3: #EEF2F7;
  --line: #E2E8F0; --line-strong: #CFD8E3;
  --ink: #0F172A; --ink-2: #475569; --ink-3: #7B8798;
  --primary: #2B9FE8; --primary-hover: #1F8FD6; --primary-ink: #1677BD; --primary-soft: #E7F3FC; --primary-ring: rgba(43, 159, 232, .28);
  --green: #5DD39E; --green-ink: #13875A; --green-soft: #E5F7EE;
  --amber: #F0A020; --amber-ink: #B26B00; --amber-soft: #FDF3E1;
  --teal-ink: #0B7F7E; --teal-soft: #E0F4F3;
  --red: #E5484D; --red-soft: #FDECEC;
  --rail: #0D1828; --rail-ink: #B3C0D3; --rail-hover: #16243A; --me: #2A3A52;
  --grad: linear-gradient(135deg, #5DD39E 0%, #2B9FE8 100%);
  --grad-soft: linear-gradient(135deg, rgba(93, 211, 158, .16) 0%, rgba(43, 159, 232, .16) 100%);
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
  --pad: 24px; /* card padding */
  --shadow-card: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 12px rgba(15, 23, 42, .035);
  --shadow-pop: 0 12px 40px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .06);
  color-scheme: light;
  font-family: "Inter Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  font-feature-settings: "ss01";
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; display: flex; min-height: 100vh; background: var(--bg); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
button, .button, a, label { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
a { color: var(--primary-ink); }

/* ---------- Rail ---------- */
aside { width: 236px; background: var(--rail); color: var(--rail-ink); padding: 26px 16px; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 8px; padding: 0 4px; margin-bottom: 6px; color: #fff; font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.brand-logo { width: 44px; height: 44px; flex: none; border-radius: var(--r-md); display: grid; place-items: center; }
.brand-logo img { width: 34px; height: 34px; display: block; }
.brand-product { font-weight: 500; color: var(--rail-ink); }
aside > .muted { padding: 0 10px; margin: 0 0 22px; color: #7f8ea3; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; }
nav { display: grid; gap: 4px; }
nav button { position: relative; display: flex; align-items: center; justify-content: flex-start; gap: 10px; background: transparent; color: var(--rail-ink); border: 0; border-radius: var(--r-md); text-align: left; padding: 11px 12px; font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: background .15s, color .15s; }
.nav-icon { width: 16px; text-align: center; }
nav button:hover { background: var(--rail-hover); color: #fff; }
nav .selected { background: var(--rail-hover); color: #fff; }
nav .selected::before { content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad); }
.aside-note { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--rail-hover); font-size: 12.5px; line-height: 1.6; }
.aside-note small { color: #7f8ea3; }
.user-name { display: block; margin-top: 14px; color: #fff; font-weight: 600; font-size: 13px; }
button.link { display: block; margin-top: 4px; background: none; border: 0; padding: 0; color: var(--rail-ink); font: inherit; font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
button.link:hover { color: #fff; }
.pill { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: auto; border-radius: 9px; background: var(--amber-soft); color: var(--amber-ink); font-size: 11px; font-weight: 700; text-align: center; }
.signed-out nav, .signed-out #alerts { display: none; }

/* ---------- Page ---------- */
main { margin-left: 236px; width: calc(100% - 236px); padding: 0 44px 56px; }
header { display: flex; justify-content: space-between; gap: 16px; padding: 22px 0; border-bottom: 1px solid var(--line); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; color: var(--ink-3); }
#connection { font-weight: 600; letter-spacing: 0; color: var(--ink-2); }
section { padding-top: 32px; }
h1 { font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; margin: 6px 0 10px; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; margin: 4px 0 16px; }
.eyebrow, .group > h2 { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary-ink); margin: 0; }
.group > h2 { margin: 30px 0 12px; }
.muted { color: var(--ink-2); line-height: 1.55; }
.small { font-size: 12px; }
.heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.badge { white-space: nowrap; padding: 7px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-ink); font-size: 12px; font-weight: 600; }
.columns { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; margin-top: 24px; align-items: start; }
.card { background: var(--surface); padding: var(--pad); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-card); margin-bottom: 16px; }
.divider { border-top: 1px solid var(--line); margin: 22px 0; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 18px; }
input, select, textarea { display: block; width: 100%; margin-top: 8px; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; line-height: 1.6; }
/* Native arrows sit against the edge and differ on every system: one centred chevron, away from the edge. */
select { -webkit-appearance: none; appearance: none; padding-right: 44px; background-image: url("/chevron.svg"); background-repeat: no-repeat; background-position: right 16px center; background-size: 12px 8px; text-overflow: ellipsis; cursor: pointer; }
/* Safari gives an empty date field no height and centres its value. */
input[type=datetime-local] { -webkit-appearance: none; appearance: none; min-height: 46px; text-align: left; }
input[type=datetime-local]::-webkit-date-and-time-value { text-align: left; }
input[type=datetime-local]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; line-height: 1.5; }
label.check input { width: auto; margin: 3px 0 0; flex: none; accent-color: var(--primary); }
.text-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: -8px; font-size: 12px; color: var(--ink-3); }

/* ---------- Buttons ---------- */
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 15px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, filter .15s; }
button:hover, .button:hover { background: var(--surface-2); border-color: var(--ink-3); }
.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.cta { background: var(--grad); border-color: transparent; color: #fff; }
.cta:hover { background: var(--grad); border-color: transparent; filter: brightness(.95) saturate(1.1); }
.danger { background: var(--amber-soft); border-color: transparent; color: var(--amber-ink); }
.danger:hover { background: #FAE8C8; border-color: transparent; }
.button.large { padding: 14px 22px; font-size: 14.5px; }
.small-button { padding: 4px 10px; font-size: 12px; margin-left: 6px; }
button:disabled { opacity: .6; cursor: wait; }

/* ---------- Messages ---------- */
#notice:not(:empty) { margin-top: 18px; padding: 12px 14px; border-radius: var(--r-md); background: var(--primary-soft); color: var(--primary-ink); font-weight: 500; }
#notice[data-tone=success]:not(:empty) { background: var(--green-soft); color: var(--green-ink); }
#notice[data-tone=error]:not(:empty) { background: var(--red-soft); color: #B42318; }
.alert { margin-top: 14px; padding: 12px 14px; border-radius: var(--r-md); background: var(--amber-soft); color: var(--amber-ink); font-size: 13px; font-weight: 500; }
.alert a { color: inherit; font-weight: 700; }
.error-text { color: var(--amber-ink); line-height: 1.55; }

/* ---------- Compose ---------- */
.profile { display: flex; gap: 12px; align-items: center; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: #fff; font-size: 17px; font-weight: 700; }
.profile strong { font-size: 13.5px; }
.preview { margin-top: 12px; }
#preview-text { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 170px; line-height: 1.6; font-size: 14px; }
.reactions { border-top: 1px solid var(--line); padding-top: 14px; font-size: 12px; color: var(--ink-3); }
.preview:has(.preview-images:not(:empty)) #preview-text { min-height: 0; }
#preview-text:empty { display: none; }
.preview-images { display: grid; gap: 3px; margin: 0 calc(-1 * var(--pad)) 14px; grid-template-columns: repeat(3, 1fr); }
.preview-images:empty { display: none; }
.preview-images[data-count="1"] .preview-image, .preview-images[data-count="3"] .preview-image:first-child, .preview-images[data-count="4"] .preview-image:first-child { grid-column: 1 / -1; }
.preview-images[data-count="2"], .preview-images[data-count="3"] { grid-template-columns: repeat(2, 1fr); }
.preview-image { position: relative; aspect-ratio: 1; background: var(--surface-3); overflow: hidden; }
.preview-images[data-count="1"] .preview-image, .preview-image:first-child:not(:only-child) { aspect-ratio: auto; max-height: 360px; }
.preview-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-images[data-count="1"] .preview-image img { object-fit: contain; max-height: 360px; }
.preview-more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15, 23, 42, .55); color: #fff; font-size: 22px; font-weight: 700; }
.preview-comment { margin-top: 14px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); font-size: 13px; }
.preview-comment strong { font-size: 12.5px; }
.preview-comment p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }

.field { margin-bottom: 18px; margin-top: 18px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.field-label { font-size: 12.5px; font-weight: 600; }
.optional { margin-left: 4px; font-weight: 500; color: var(--ink-3); }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.image-grid:not(:empty) { margin-bottom: 10px; }
.image-tile { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); }
.image-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--surface-3); }
.image-tile.pending { aspect-ratio: 1; display: grid; place-items: center; }
.tile-tools { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.tile-button { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: rgba(15, 23, 42, .62); color: #fff; font-size: 12px; }
.tile-button:hover { background: rgba(15, 23, 42, .82); border: 0; }
.tile-alt { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 7px 9px; font-size: 12px; }
.tile-alt:focus { box-shadow: none; background: var(--primary-soft); }
.dropzone { display: grid; gap: 4px; justify-items: center; text-align: center; margin: 0; padding: 16px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone-title { color: var(--primary-ink); font-size: 13px; font-weight: 600; }
.hint { background: var(--grad-soft); border-radius: var(--r-lg); padding: 18px 20px; font-size: 13px; line-height: 1.6; }
.hint p { color: var(--ink-2); margin: 4px 0 0; }

/* ---------- Planning ---------- */
.post-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.post-meta { display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: 12.5px; color: var(--ink-3); }
.status { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); }
.status.scheduled { background: var(--primary-soft); color: var(--primary-ink); }
.status.sending { background: var(--teal-soft); color: var(--teal-ink); }
.status.published { background: var(--green-soft); color: var(--green-ink); }
.status.failed, .status.uncertain { background: var(--amber-soft); color: var(--amber-ink); }
.post.failed, .post.uncertain { border-color: #F3D9A8; }
.post-actions { margin-top: 14px; }
.post.comment-todo { border-color: #F3D9A8; }
.post-images { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.post-images img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }
.post-images-more { width: 64px; height: 64px; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--surface-3); color: var(--ink-2); font-weight: 700; }
.post-comment { margin-top: 12px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); border-left: 3px solid var(--line-strong); }
.post-comment.sent { border-left-color: var(--green); }
.post-comment.failed, .post-comment.uncertain { border-left-color: var(--amber); background: var(--amber-soft); }
.comment-text { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.comment-edit { margin: 8px 0 6px; }
.post-comment .actions { margin-top: 10px; }

/* ---------- Accounts and setup ---------- */
#login { max-width: 640px; }
#setup { margin-top: 24px; max-width: 760px; }
.steps { padding-left: 20px; margin: 0 0 22px; }
.steps li { margin-bottom: 10px; line-height: 1.65; font-size: 13.5px; }
.steps a { font-weight: 600; }
code { background: var(--surface-3); padding: 2px 7px; border-radius: 6px; font-size: 12.5px; overflow-wrap: anywhere; }
.account strong { font-size: 14.5px; }
.account .danger { margin-top: 4px; }
.danger-zone { margin-top: 32px; }
.danger-zone strong { color: var(--amber-ink); }

/* ---------- Medium widths (unfolded foldables in landscape, tablets): the preview goes under the form ---------- */
@media (max-width: 1100px) {
  .columns { grid-template-columns: minmax(0, 1fr); max-width: 720px; }
}

/* ---------- Small screens: the rail becomes a top bar (Charik CRM breakpoints) ---------- */
@media (max-width: 900px) {
  body { display: block; }
  /* Room for the notch, the Dynamic Island and rounded corners (viewport-fit=cover). */
  aside { position: static; width: auto; padding: calc(12px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 12px calc(16px + env(safe-area-inset-left)); }
  aside > .muted { display: none; }
  .brand { margin: 0 0 10px; }
  nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  nav button { justify-content: center; gap: 6px; white-space: nowrap; padding: 10px 6px; font-size: 13px; }
  nav .selected::before { display: none; }
  .pill { margin-left: 2px; }
  .aside-note { margin-top: 10px; padding-top: 10px; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
  .aside-note small, .aside-note br { display: none; }
  .user-name, button.link { margin-top: 0; }
  main { margin: 0; width: 100%; padding: 0 calc(16px + env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
  .heading { display: block; }
  .badge { display: inline-block; margin-top: 8px; }
}
@media (max-width: 600px) {
  :root { --pad: 18px; }
  h1 { font-size: 24px; }
  header { font-size: 10.5px; }
  .post-meta { flex-wrap: wrap; }
  .columns { margin-top: 18px; gap: 18px; }
  .group > h2 { margin-top: 24px; }
}
/* Narrow phones: short menu labels, and no icons on the smallest ones. */
@media (max-width: 520px) {
  .long, .tagline { display: none; }
  /* Form buttons stacked full width, the main action first. */
  #post-form .actions { flex-direction: column; align-items: stretch; }
  #post-form .actions .cta { order: -1; }
}
@media (max-width: 360px) {
  .nav-icon { display: none; }
  .actions > button, .actions > .button { flex: 1 1 auto; }
}

/* ---------- Touch screens ---------- */
@media (pointer: coarse) {
  /* Under 16px, Safari on iPhone zooms into the field and leaves the page zoomed. */
  input, select, textarea, .tile-alt { font-size: 16px; }
  button, .button { min-height: 44px; }
  nav button { min-height: 42px; }
  .tile-button { width: 36px; height: 36px; min-height: 0; font-size: 14px; }
  .small-button { min-height: 34px; }
  button.link { min-height: 0; padding: 6px 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
