/*
 * Tootframe — design system.
 * Translated 1:1 from the original Tailwind v4 / oklch theme (src/styles.css).
 * Requires a modern browser (oklch support, same as the original app).
 */

:root {
  --radius: 0.375rem;

  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --background: oklch(0.145 0.012 240);
  --foreground: oklch(0.94 0.01 90);
  --card: oklch(0.18 0.012 240);
  --card-foreground: oklch(0.94 0.01 90);
  --popover: oklch(0.18 0.012 240);
  --popover-foreground: oklch(0.94 0.01 90);
  --primary: oklch(0.82 0.16 91);
  --primary-foreground: oklch(0.16 0.02 90);
  --secondary: oklch(0.24 0.014 240);
  --secondary-foreground: oklch(0.94 0.01 90);
  --muted: oklch(0.25 0.012 240);
  --muted-foreground: oklch(0.67 0.016 240);
  --accent: oklch(0.22 0.018 210);
  --accent-foreground: oklch(0.94 0.01 90);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.984 0.003 247.858);
  --border: oklch(0.31 0.014 240);
  --input: oklch(0.31 0.014 240);
  --ring: oklch(0.82 0.16 91);
  --panel: oklch(0.175 0.012 240);
  --overlay: oklch(0.12 0.01 240 / 78%);
  --overlay-foreground: oklch(0.96 0.005 90);
  --frame-white: oklch(0.97 0.006 90);
  --frame-black: oklch(0.08 0.005 240);
  --warning: oklch(0.78 0.17 55);
  --success: oklch(0.74 0.16 155);

  /* Alpha variants (the original's Tailwind slash-opacity utilities) */
  --border-70: oklch(0.31 0.014 240 / 70%);
  --primary-90: oklch(0.82 0.16 91 / 90%);
  --primary-70: oklch(0.82 0.16 91 / 70%);
  --primary-60: oklch(0.82 0.16 91 / 60%);
  --primary-15: oklch(0.82 0.16 91 / 15%);
  --accent-60: oklch(0.22 0.018 210 / 60%);
  --panel-60: oklch(0.175 0.012 240 / 60%);
  --panel-40: oklch(0.175 0.012 240 / 40%);
  --destructive-40: oklch(0.577 0.245 27.325 / 40%);
  --destructive-10: oklch(0.577 0.245 27.325 / 10%);
  --success-50: oklch(0.74 0.16 155 / 50%);
  --muted-foreground-55: oklch(0.67 0.016 240 / 55%);
  --neutral-500: #737373;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  border-color: var(--border);
}

[hidden] {
  display: none !important;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  letter-spacing: 0;
  min-width: 320px;
}

button,
textarea,
input {
  letter-spacing: 0;
  font-family: inherit;
}

img {
  display: block;
}

.text-warning {
  color: var(--warning);
}

/* ---------- Icons ---------- */

[data-icon] {
  display: inline-flex;
  flex-shrink: 0;
}

[data-icon] svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.spinning svg,
.spinning {
  animation: tf-spin 1s linear infinite;
}

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

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  border-radius: var(--radius);
  border: 1px solid transparent;
  height: 36px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 1px var(--ring);
}

.btn:disabled {
  pointer-events: none;
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-default {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-default:hover {
  background: var(--primary-90);
}

.btn-outline {
  border-color: var(--input);
  background: var(--background);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-outline:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-ghost {
  background: transparent;
}

.btn-ghost:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-icon {
  height: 36px;
  width: 36px;
  padding: 0;
}

.btn-lg {
  height: 40px;
  padding: 0 32px;
  border-radius: var(--radius);
}

.btn-logout {
  border-color: var(--success-50);
  color: var(--success);
}

.btn-logout:hover {
  color: var(--success);
}

/* ---------- Header ---------- */

.page {
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
}

.site-header {
  border-bottom: 1px solid var(--border-70);
  padding: 16px 20px;
}

.header-inner {
  margin: 0 auto;
  display: flex;
  max-width: 1500px;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--primary);
  font-size: 14px;
  font-weight: 900;
  color: var(--primary-foreground);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted-foreground);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-acct {
  display: none;
  font-size: 12px;
  color: var(--muted-foreground);
}

@media (min-width: 640px) {
  .session-acct {
    display: inline;
  }
}

/* ---------- Layout ---------- */

.layout {
  margin: 0 auto;
  max-width: 1500px;
  display: grid;
}

.composer-col {
  min-width: 0;
}

@media (min-width: 1024px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 390px;
  }

  .composer-col {
    border-right: 1px solid var(--border);
  }
}

/* ---------- Error banner ---------- */

.error-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--destructive-40);
  background: var(--destructive-10);
  padding: 12px 20px;
  font-size: 14px;
  color: var(--destructive);
}

.error-banner p {
  min-width: 0;
  flex: 1;
  margin: 0;
  line-height: 1.625;
}

.error-icon {
  margin-top: 2px;
}

.error-close {
  flex-shrink: 0;
  opacity: 0.7;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  transition: opacity 150ms ease;
}

.error-close:hover {
  opacity: 1;
}

@media (min-width: 768px) {
  .error-banner {
    padding: 12px 40px;
  }
}

/* ---------- Post box ---------- */

.post-box {
  border-bottom: 1px solid var(--border-70);
  padding: 28px 20px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--primary);
}

.post-textarea {
  min-height: 128px;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  background: var(--panel-40);
  padding: 12px 16px;
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.375;
  outline: none;
  transition: border-color 150ms ease;
  color: var(--foreground);
}

.post-textarea::placeholder {
  color: var(--muted-foreground-55);
}

.post-textarea:focus {
  border-color: var(--primary-60);
}

.char-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 12px;
  font-size: 12px;
  color: var(--muted-foreground);
}

@media (min-width: 768px) {
  .post-box {
    padding: 28px 40px;
  }

  .post-textarea {
    font-size: 30px;
  }
}

/* ---------- Photo section ---------- */

.photo-section {
  padding: 28px 20px;
  transition: background-color 150ms ease;
}

.photo-section.drag-active {
  background: var(--accent-60);
  box-shadow: inset 0 0 0 1px var(--primary-60);
}

.photo-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.photo-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
}

.photo-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted-foreground);
}

@media (min-width: 768px) {
  .photo-section {
    padding: 28px 40px;
  }
}

/* Empty state */

.empty-state {
  display: flex;
  min-height: 288px;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  background: var(--panel);
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
  color: inherit;
}

.empty-state:hover {
  border-color: var(--primary-70);
  background: var(--accent);
}

.empty-icon {
  margin-bottom: 16px;
  display: flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--muted-foreground);
  transition: color 150ms ease;
}

.empty-icon svg {
  width: 20px;
  height: 20px;
}

.empty-state:hover .empty-icon {
  color: var(--primary);
}

.empty-title {
  font-size: 14px;
  font-weight: 500;
}

.empty-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted-foreground);
}

/* Photo grid */

.photo-grid {
  display: grid;
  max-width: 640px;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.photo-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--panel);
}

.photo-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.photo-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
}

.photo-thumb img {
  height: 100%;
  width: 100%;
  object-fit: cover;
}

.photo-index {
  position: absolute;
  left: 8px;
  top: 8px;
  display: flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: var(--overlay);
  font-size: 11px;
  font-weight: 600;
  color: var(--overlay-foreground);
}

.photo-trash {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 9999px;
  background: var(--overlay);
  color: var(--overlay-foreground);
  opacity: 0;
  padding: 0;
  cursor: pointer;
  transition: opacity 150ms ease;
}

.photo-trash svg {
  width: 12px;
  height: 12px;
}

.photo-card:hover .photo-trash {
  opacity: 1;
}

.photo-alt-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: none;
  background: none;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  color: var(--warning);
  transition: background-color 150ms ease, color 150ms ease;
}

.photo-alt-toggle.has-alt {
  color: var(--success);
}

.photo-alt-toggle.active {
  background: var(--primary-15);
  color: var(--primary);
}

.photo-alt-toggle.over-limit {
  color: var(--destructive);
}

.alt-dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: currentColor;
}

.photo-add {
  display: flex;
  flex-direction: column;
  border: 1px dashed var(--border);
  background: none;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
}

.photo-add:hover {
  border-color: var(--primary-70);
  color: var(--primary);
}

.photo-add-icon {
  display: flex;
  aspect-ratio: 4 / 5;
  align-items: center;
  justify-content: center;
}

.photo-add-icon svg {
  width: 20px;
  height: 20px;
}

.photo-add-label {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 500;
}

/* ---------- Detail: alt editor + preview ---------- */

.detail {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.alt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.alt-head label {
  font-size: 14px;
  font-weight: 600;
}

.alt-len {
  font-size: 12px;
  color: var(--muted-foreground);
}

.text-destructive {
  color: var(--destructive);
}

.alt-textarea {
  min-height: 144px;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 16px;
  font-size: 14px;
  line-height: 1.625;
  outline: none;
  transition: border-color 150ms ease;
  color: var(--foreground);
}

.alt-textarea:focus {
  border-color: var(--primary);
}

.alt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.btn-generate {
  min-width: 176px;
}

.preview-wrap {
  display: flex;
  min-height: 288px;
  min-width: 0;
  align-items: center;
  justify-content: center;
  background: var(--neutral-500);
  padding: 20px;
}

.frame-preview {
  margin: 0 auto;
  display: flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  transition: padding 180ms ease, background-color 180ms ease;
}

.frame-preview img {
  max-height: 480px;
  max-width: 100%;
  object-fit: contain;
}

.frame-light {
  background: var(--frame-white);
}

.frame-dark {
  background: var(--frame-black);
}

.frame-none {
  background: transparent;
}

/* ---------- Sidebar ---------- */

.side-col {
  background: var(--panel-60);
  padding: 28px 20px;
}

.side-sticky {
  position: sticky;
  top: 24px;
}

.side-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
}

.side-head [data-icon] {
  color: var(--primary);
}

.side-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

.side-head span {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted-foreground);
}

.side-controls {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.control-label {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.frame-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.frame-option {
  height: auto;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px;
  font-size: 11px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 9999px;
  border: 1px solid var(--border);
}

.swatch-none {
  border-style: dashed;
  border-color: var(--muted-foreground);
}

.swatch-white {
  background: var(--frame-white);
}

.swatch-black {
  background: var(--frame-black);
}

.frame-sliders {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.slider-block {
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 12px;
}

.slider-row label {
  font-weight: 500;
  color: var(--muted-foreground);
}

.slider-value {
  font-family: var(--font-mono);
  color: var(--foreground);
}

.frame-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.625;
  color: var(--muted-foreground);
}

.side-divider {
  margin: 32px 0;
  border-top: 1px solid var(--border);
}

.alt-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--muted-foreground);
}

.btn-publish {
  height: 48px;
  width: 100%;
  justify-content: center;
  gap: 8px;
  padding: 0 32px;
}

.notice {
  margin: 16px 0 0;
  font-size: 12px;
  line-height: 1.625;
  color: var(--muted-foreground);
}

.posted-link {
  display: block;
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 4px;
}

@media (min-width: 768px) {
  .side-col {
    padding: 28px 32px;
  }
}

@media (min-width: 1024px) {
  .side-col {
    min-height: calc(100vh - 65px);
  }
}

/* ---------- Range controls ---------- */

.range-control {
  width: 100%;
  height: 4px;
  appearance: none;
  border-radius: 99px;
  background: var(--muted);
  accent-color: var(--primary);
  cursor: pointer;
}

.range-control::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  appearance: none;
  border: 3px solid var(--background);
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.range-control::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 3px solid var(--background);
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* ---------- Dialogs ---------- */

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  padding: 16px;
}

.dialog-overlay.open {
  animation: tf-fade-in 150ms ease-out;
}

.dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 512px;
  border: 1px solid var(--border);
  background: var(--background);
  padding: 24px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  border-radius: var(--radius);
}

.dialog-overlay.open .dialog {
  animation: tf-zoom-in 150ms ease-out;
}

@media (min-width: 640px) {
  .dialog {
    border-radius: 8px;
  }
}

@keyframes tf-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes tf-zoom-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.dialog-close {
  position: absolute;
  right: 16px;
  top: 16px;
  border: none;
  background: none;
  padding: 0;
  border-radius: 4px;
  opacity: 0.7;
  cursor: pointer;
  color: inherit;
  transition: opacity 150ms ease;
}

.dialog-close:hover {
  opacity: 1;
}

.dialog-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
}

.dialog-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
}

.dialog-desc {
  margin: 0;
  font-size: 14px;
  color: var(--muted-foreground);
}

.dialog-footer {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

@media (min-width: 640px) {
  .dialog-header {
    text-align: left;
  }

  .dialog-footer {
    flex-direction: row;
    justify-content: flex-end;
  }
}

/* ---------- Form fields ---------- */

.text-input {
  display: flex;
  height: 36px;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--input);
  background: transparent;
  padding: 4px 12px;
  font-size: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: border-color 150ms ease;
  color: var(--foreground);
}

.text-input::placeholder {
  color: var(--muted-foreground);
}

.text-input:focus {
  outline: none;
  border-color: var(--ring);
}

.prompt-textarea {
  min-height: 128px;
  width: 100%;
  resize: vertical;
  border-radius: var(--radius);
  border: 1px solid var(--input);
  background: transparent;
  padding: 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 150ms ease;
  color: var(--foreground);
}

.prompt-textarea::placeholder {
  color: var(--muted-foreground);
}

.prompt-textarea:focus {
  border-color: var(--primary);
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground);
}

@media (min-width: 768px) {
  .text-input {
    font-size: 14px;
  }
}

/* ---------- OAuth callback page ---------- */

.callback-body {
  min-height: 100vh;
  background: #0f141a;
  color: #ddd;
  font-family: ui-sans-serif, system-ui, sans-serif;
  padding: 2rem;
  margin: 0;
}

.callback-box {
  max-width: 32rem;
  margin: 0 auto;
  line-height: 1.6;
}

.callback-back {
  color: oklch(0.82 0.16 91);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
