/* TalkBlog — minimal, modern, iOS-styled. */

/* ---------------------------------------------------------------- *
 * Tokens
 * ---------------------------------------------------------------- */
:root {
  --tb-bg:        #ffffff;
  --tb-surface:   #ffffff;
  --tb-surface-2: #fafafa;
  --tb-fg:        #0a0a0a;
  --tb-muted:     #71717a;
  --tb-line:      #e4e4e7;
  --tb-line-soft: #f1f1f4;
  --tb-accent:    #0a0a0a;
  --tb-danger:    #dc2626;
  --tb-success:   #16a34a;
  --tb-info:      #2563eb;

  --tb-radius-sm: 8px;
  --tb-radius:    14px;
  --tb-radius-lg: 20px;

  --tb-shadow-1:  0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.03);
  --tb-shadow-2:  0 4px 14px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --tb-shadow-3:  0 12px 36px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);

  --tb-fs-xs: 12px;
  --tb-fs-sm: 14px;
  --tb-fs-md: 16px;
  --tb-fs-lg: 20px;
  --tb-fs-xl: 28px;
  --tb-fs-2xl: 36px;

  --ion-font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Inter", "Segoe UI", Roboto, system-ui, sans-serif;

  --ion-background-color: var(--tb-bg);
  --ion-text-color:       var(--tb-fg);
  --ion-toolbar-background: var(--tb-bg);
  --ion-item-background:    var(--tb-bg);
  --ion-tab-bar-background: var(--tb-bg);

  --ion-border-color: var(--tb-line);
}

@media (prefers-color-scheme: dark) {
  :root {
    --tb-bg:        #0a0a0a;
    --tb-surface:   #111113;
    --tb-surface-2: #161618;
    --tb-fg:        #fafafa;
    --tb-muted:     #a1a1aa;
    --tb-line:      #27272a;
    --tb-line-soft: #1c1c1f;
    --tb-accent:    #fafafa;

    --tb-shadow-1:  0 1px 2px rgba(0,0,0,.4);
    --tb-shadow-2:  0 4px 14px rgba(0,0,0,.5);
    --tb-shadow-3:  0 12px 36px rgba(0,0,0,.6);
  }
}

/* ---------------------------------------------------------------- *
 * Base
 * ---------------------------------------------------------------- */
html, body {
  margin: 0; padding: 0;
  background: var(--tb-bg);
  color: var(--tb-fg);
  font-family: var(--ion-font-family);
  font-size: var(--tb-fs-md);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

a { color: var(--tb-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--tb-fg); }

/* Ionic component overrides */
ion-toolbar {
  --background: var(--tb-bg);
  --color: var(--tb-fg);
  --border-color: var(--tb-line);
  --min-height: 52px;
}
ion-title {
  font-weight: 600;
  letter-spacing: -0.01em;
}
ion-content {
  --background: var(--tb-bg);
}
ion-item {
  --background: var(--tb-bg);
  --color: var(--tb-fg);
  --border-color: var(--tb-line-soft);
  --inner-padding-end: 16px;
  --padding-start: 16px;
  --min-height: 60px;
}
ion-list {
  background: var(--tb-bg);
  padding: 0;
}
ion-label h2 {
  font-weight: 600 !important;
  font-size: 16px !important;
  letter-spacing: -0.01em;
  margin-bottom: 2px !important;
}
ion-label p {
  font-size: 13px !important;
  color: var(--tb-muted) !important;
}
ion-button {
  --border-radius: 10px;
  --box-shadow: none;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-transform: none;
}
ion-fab-button {
  --box-shadow: var(--tb-shadow-3);
}
ion-input {
  --background: var(--tb-bg);
  --color: var(--tb-fg);
  --border-color: var(--tb-line);
  --border-radius: 10px;
  --padding-start: 14px !important;
  --padding-end: 14px !important;
  --highlight-color-focused: var(--tb-fg);
  font-size: 16px;
}
ion-textarea {
  --background: var(--tb-bg);
  --color: var(--tb-fg);
  --border-color: var(--tb-line);
  --border-radius: 10px;
  --padding-start: 14px;
  font-size: 15px;
}
ion-spinner {
  --color: var(--tb-fg);
}

ion-action-sheet,
ion-alert,
ion-popover,
ion-modal {
  --ion-background-color: #fff;
  --ion-text-color: #000;
  --ion-item-background: #fff;
  --ion-toolbar-background: #fff;
  --ion-border-color: #c1c4cc;
}
@media (prefers-color-scheme: dark) {
  ion-action-sheet,
  ion-alert,
  ion-popover,
  ion-modal {
    --ion-background-color: #1c1c1e;
    --ion-text-color: #fff;
    --ion-item-background: #1c1c1e;
    --ion-toolbar-background: #1c1c1e;
    --ion-border-color: #38383a;
  }
}

/* ---------------------------------------------------------------- *
 * Layout helpers
 * ---------------------------------------------------------------- */
.tb-page-pad { padding: 16px 20px; }

.tb-h1 {
  font-size: var(--tb-fs-2xl);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 8px 0 12px;
}
.tb-h2 {
  font-size: var(--tb-fs-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.tb-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tb-muted);
  margin: 24px 20px 6px;
}
.tb-muted { color: var(--tb-muted); }
.tb-row { display: flex; align-items: center; gap: 8px; }
.tb-spacer { flex: 1; }

/* ---------------------------------------------------------------- *
 * Empty states
 * ---------------------------------------------------------------- */
.tb-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  text-align: center; padding: 64px 24px;
  color: var(--tb-muted);
  min-height: 50vh;
}
.tb-empty .tb-empty-icon {
  width: 64px; height: 64px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--tb-surface-2);
  color: var(--tb-muted);
}
.tb-empty .tb-empty-icon ion-icon { font-size: 28px; }
.tb-empty h2 {
  color: var(--tb-fg); margin: 0 0 6px;
  font-size: 20px; font-weight: 600; letter-spacing: -0.015em;
}
.tb-empty p { margin: 0 0 20px; max-width: 280px; line-height: 1.5; }

/* ---------------------------------------------------------------- *
 * Snippet row
 * ---------------------------------------------------------------- */
.tb-snippet {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--tb-line-soft);
  background: var(--tb-bg);
  transition: background-color 120ms ease;
}
.tb-snippet:hover { background: var(--tb-surface-2); }
.tb-snippet[data-dragging="true"] { opacity: 0.4; }
.tb-snippet[data-drop="true"] {
  background: var(--tb-line-soft);
  box-shadow: inset 0 2px 0 var(--tb-fg);
}

.tb-snippet .handle {
  color: var(--tb-muted);
  cursor: grab; user-select: none;
  font-size: 16px;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 150ms, color 150ms;
}
.tb-snippet:hover .handle,
.tb-snippet:active .handle { opacity: 1; color: var(--tb-fg); }
.tb-snippet .handle:active { cursor: grabbing; }

.tb-snippet .play-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--tb-line);
  background: var(--tb-bg);
  color: var(--tb-fg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 120ms ease;
}
.tb-snippet .play-btn:hover {
  background: var(--tb-fg);
  color: var(--tb-bg);
  border-color: var(--tb-fg);
}
.tb-snippet .play-btn[data-playing="true"] {
  background: var(--tb-fg);
  color: var(--tb-bg);
  border-color: var(--tb-fg);
}
.tb-snippet .play-btn ion-icon { font-size: 14px; }

.tb-snippet .meta { flex: 1; min-width: 0; }
.tb-snippet .meta .title {
  font-weight: 500; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.005em;
  color: var(--tb-fg);
}
.tb-snippet .meta .sub {
  font-size: 12px; color: var(--tb-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.tb-snippet input.title-edit {
  width: 100%; border: none; background: transparent;
  color: var(--tb-fg); font: inherit; font-weight: 500; font-size: 15px;
  outline: none; padding: 0;
  border-bottom: 1px solid var(--tb-fg);
}

.tb-snippet .delete-btn {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--tb-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.7;
  transition: all 120ms;
}
.tb-snippet .delete-btn:hover {
  background: var(--tb-line-soft);
  color: var(--tb-danger);
  opacity: 1;
}
.tb-snippet .delete-btn:active {
  background: var(--tb-line);
  color: var(--tb-danger);
}

/* ---------------------------------------------------------------- *
 * Toolbar action row (Play all / Render / Invite)
 * ---------------------------------------------------------------- */
.tb-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px 8px;
  border-bottom: 1px solid var(--tb-line-soft);
  background: var(--tb-bg);
}
.tb-actions ion-button { margin: 0; }

/* ---------------------------------------------------------------- *
 * Recording pill
 * ---------------------------------------------------------------- */
.tb-recording-pill {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(108px + env(safe-area-inset-bottom));
  z-index: 100;
  background: var(--tb-danger); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  letter-spacing: -0.005em;
  box-shadow: var(--tb-shadow-3);
  display: flex; align-items: center; gap: 10px;
  font-variant-numeric: tabular-nums;
  animation: tb-pop-in 200ms cubic-bezier(.2,.8,.2,1.2);
}
.tb-recording-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #fff; animation: tb-pulse 1.2s infinite ease-in-out;
}
@keyframes tb-pulse { 0%,100% { opacity:1; transform: scale(1); }
                      50%     { opacity:.4; transform: scale(.8); } }
@keyframes tb-pop-in { from { opacity:0; transform: translateX(-50%) translateY(8px) scale(.95); }
                      to   { opacity:1; transform: translateX(-50%) translateY(0)   scale(1); } }

/* ---------------------------------------------------------------- *
 * Render cards
 * ---------------------------------------------------------------- */
.tb-render-card {
  border: 1px solid var(--tb-line);
  border-radius: var(--tb-radius);
  padding: 16px;
  margin: 10px 20px;
  background: var(--tb-surface);
  box-shadow: var(--tb-shadow-1);
  transition: box-shadow 150ms;
}
.tb-render-card:hover { box-shadow: var(--tb-shadow-2); }

.tb-renders-dropdown {
  margin: 16px 20px 0;
  border: 1px solid var(--tb-line);
  border-radius: var(--tb-radius);
  overflow: hidden;
  background: var(--tb-surface);
}
.tb-renders-toggle {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 12px 16px;
  background: var(--tb-surface); border: none;
  color: var(--tb-fg); font: inherit; font-size: 15px;
  font-weight: 600; letter-spacing: -0.005em;
  cursor: pointer; text-align: left;
}
.tb-renders-toggle:hover { background: var(--tb-surface-2); }
.tb-renders-toggle .tb-badge {
  font-size: 11px; font-weight: 600;
  background: var(--tb-line-soft); color: var(--tb-muted);
  padding: 2px 8px; border-radius: 999px;
  letter-spacing: 0.02em;
}
.tb-renders-toggle .chevron {
  margin-left: auto; font-size: 18px; color: var(--tb-muted);
  transition: transform 150ms ease;
}
.tb-renders-toggle .chevron.open { transform: rotate(180deg); }
.tb-renders-body {
  max-height: 0; overflow: hidden;
  transition: max-height 250ms cubic-bezier(.4,0,.2,1);
}
.tb-renders-body.open { max-height: 2000px; }
.tb-renders-body .tb-render-card {
  margin: 0; border-radius: 0;
  border-top: 1px solid var(--tb-line-soft);
  border-left: none; border-right: none; border-bottom: none;
  box-shadow: none;
}
.tb-renders-body .tb-render-card:last-child { border-bottom: none; }
.tb-render-card .row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
}
.tb-render-card .kind {
  font-weight: 600; font-size: 15px;
  letter-spacing: -0.01em;
}
.tb-render-card .desc {
  font-size: 13px; color: var(--tb-muted); margin-top: 2px;
}
.tb-render-card .status {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--tb-line-soft); color: var(--tb-muted);
}
.tb-render-card .status.done    { background: var(--tb-success); color: #fff; }
.tb-render-card .status.failed  { background: var(--tb-danger);  color: #fff; }
.tb-render-card .status.running,
.tb-render-card .status.pending { background: var(--tb-info);    color: #fff; }

/* ---------------------------------------------------------------- *
 * Pills, badges
 * ---------------------------------------------------------------- */
.tb-balance-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--tb-line);
  font-size: 13px; font-weight: 600;
  color: var(--tb-fg);
  font-variant-numeric: tabular-nums;
}

ion-badge {
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------------- *
 * Replies
 * ---------------------------------------------------------------- */
.tb-reply {
  padding: 14px 20px;
  border-bottom: 1px solid var(--tb-line-soft);
}
.tb-reply .who { font-weight: 600; font-size: 14px; }
.tb-reply .when { font-size: 12px; color: var(--tb-muted); margin-left: 8px; }
.tb-reply .body { margin: 4px 0 0; font-size: 15px; line-height: 1.5; }

/* ---------------------------------------------------------------- *
 * Auth screens
 * ---------------------------------------------------------------- */
.tb-auth-card {
  max-width: 400px;
  margin: 0 auto;
  padding: 80px 24px 24px;
}
.tb-auth-card .brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 36px;
}
.tb-auth-card .brand .logo {
  width: 36px; height: 36px;
  background: var(--tb-fg); color: var(--tb-bg);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.tb-auth-card .brand .name {
  font-weight: 700; font-size: 18px; letter-spacing: -0.02em;
}
.tb-auth-card h1 {
  font-size: 30px; font-weight: 700; letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 8px;
}
.tb-auth-card .subtitle {
  color: var(--tb-muted);
  margin: 0 0 28px;
  line-height: 1.5;
  font-size: 15px;
}
.tb-auth-card .switch {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--tb-muted);
}
.tb-auth-card .switch a {
  color: var(--tb-fg); font-weight: 600;
}

/* ---------------------------------------------------------------- *
 * Errors
 * ---------------------------------------------------------------- */
.tb-error {
  background: rgba(220, 38, 38, 0.08);
  color: var(--tb-danger);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin: 0 0 12px;
  border: 1px solid rgba(220, 38, 38, 0.2);
  font-weight: 500;
}

@media (prefers-color-scheme: dark) {
  .tb-error { background: rgba(220, 38, 38, 0.15); color: #fca5a5; }
}

/* ---------------------------------------------------------------- *
 * Workspace list (ion-item-sliding rows)
 * ---------------------------------------------------------------- */
.tb-ws-list {
  background: transparent !important;
  padding: 0;
}
ion-item.tb-ws-item {
  --background: var(--tb-bg);
  --background-hover: var(--tb-surface-2);
  --background-activated: var(--tb-line-soft);
  --color: var(--tb-fg);
  --border-color: var(--tb-line-soft);
  --inner-padding-end: 8px;
  --padding-start: 20px;
  --min-height: 64px;
  border-bottom: 1px solid var(--tb-line-soft);
}
ion-item.tb-ws-item .title-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
ion-item.tb-ws-item .title-row .title {
  font-weight: 600; font-size: 16px; letter-spacing: -0.01em;
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
ion-item.tb-ws-item .meta {
  font-size: 13px; color: var(--tb-muted);
  font-variant-numeric: tabular-nums;
}

/* Inline trash button on the row (visible on desktop + mobile) */
.tb-row-delete {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--tb-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.7;
  transition: all 120ms;
  margin-left: 8px;
}
.tb-row-delete:hover {
  background: var(--tb-line-soft);
  color: var(--tb-danger);
  opacity: 1;
}
.tb-row-delete:active {
  background: var(--tb-line);
  color: var(--tb-danger);
}
.tb-row-delete ion-icon { font-size: 18px; }

/* ---------------------------------------------------------------- *
 * FAB
 * ---------------------------------------------------------------- */
.tb-record-fab {
  --background: var(--tb-danger);
  --color: white;
}
ion-fab-button.tb-rec-active {
  --background: var(--tb-fg);
}

/* ---------------------------------------------------------------- *
 * Misc
 * ---------------------------------------------------------------- */
.tb-divider {
  height: 1px; background: var(--tb-line-soft);
  margin: 0 20px;
}
.tb-section { padding: 16px 20px; }

/* Make ion-buttons in headers look cleaner */
ion-buttons ion-button { --color: var(--tb-fg); }

/* Make form selects/inputs play nice in light mode */
ion-input.ios::part(native) { padding-left: 14px; }



/* Slightly larger tap targets on mobile */
@media (max-width: 640px) {
  ion-button { --padding-start: 14px; --padding-end: 14px; min-height: 40px; }
}

/* ---------------------------------------------------------------- *
 * Modal: render-modal layout (plain CSS, no <ion-content>)
 *
 * The render modal is a custom-element host filling its parent
 * <ion-modal>. We own the internal scroll container so Ionic's
 * shadow-DOM sizing of nested <ion-content> doesn't make the
 * usable area collapse to nothing.
 * ---------------------------------------------------------------- */
tb-render-modal {
  display: block;
  width: 100%;
  height: 100%;
}
.tb-modal-shell {
  display: flex; flex-direction: column;
  height: 100%; width: 100%;
  background: var(--tb-bg);
  color: var(--tb-fg);
}
.tb-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--tb-line-soft);
  flex-shrink: 0;
}
.tb-modal-title {
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
}
.tb-modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--tb-line-soft);
  color: var(--tb-fg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background-color 120ms;
}
.tb-modal-close:hover { background: var(--tb-line); }
.tb-modal-close ion-icon { font-size: 18px; }

.tb-modal-body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tb-modal-summary { padding: 16px 20px; }
.tb-modal-list {
  border-top: 1px solid var(--tb-line-soft);
}

.tb-render-option {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  background: var(--tb-bg);
  border: none;
  border-bottom: 1px solid var(--tb-line-soft);
  text-align: left;
  cursor: pointer;
  color: var(--tb-fg);
  font-family: inherit;
  transition: background-color 120ms;
}
.tb-render-option:hover:not([disabled]) { background: var(--tb-surface-2); }
.tb-render-option:active:not([disabled]) { background: var(--tb-line-soft); }
.tb-render-option[disabled] { opacity: 0.5; cursor: not-allowed; }
.tb-render-option .opt-icon {
  flex-shrink: 0;
  font-size: 22px;
  color: var(--tb-muted);
}
.tb-render-option .opt-meta { flex: 1; min-width: 0; }
.tb-render-option .opt-title {
  font-weight: 600; font-size: 15px;
  letter-spacing: -0.005em;
  margin-bottom: 2px;
}
.tb-render-option .opt-desc {
  font-size: 13px; color: var(--tb-muted);
  line-height: 1.4;
}
.tb-render-option .opt-end {
  flex-shrink: 0;
  font-size: 18px;
  color: var(--tb-muted);
}

/* ---------------------------------------------------------------- *
 * Members modal
 * ---------------------------------------------------------------- */
.tb-member-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--tb-line-soft);
}
.tb-member-meta { flex: 1; min-width: 0; }
.tb-member-name {
  font-weight: 600; font-size: 15px;
  letter-spacing: -0.005em;
  color: var(--tb-fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tb-member-sub {
  font-size: 13px; color: var(--tb-muted);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tb-member-role {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.tb-role-pill {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--tb-line-soft); color: var(--tb-muted);
}
.tb-role-pill.owner {
  background: var(--tb-fg); color: var(--tb-bg);
}
.tb-role-select {
  font: inherit; font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--tb-line);
  border-radius: 8px;
  background: var(--tb-bg); color: var(--tb-fg);
  cursor: pointer;
}
.tb-member-remove {
  width: 32px; height: 32px;
  border-radius: 50%; border: none;
  background: transparent;
  color: var(--tb-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 120ms;
}
.tb-member-remove:hover {
  background: var(--tb-line-soft);
  color: var(--tb-danger);
}
.tb-member-remove ion-icon { font-size: 18px; }
