*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --segmented-bg: rgba(118, 118, 128, 0.12);
  --separator: rgba(60, 60, 67, 0.18);
  --accent: #4a9a8a;
  --accent-dim: rgba(74, 154, 138, 0.14);
  --text: #000000;
  --text-secondary: rgba(60, 60, 67, 0.6);
  --text-tertiary: rgba(60, 60, 67, 0.3);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius-card: 13px;
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --nav-height: 52px;
  --bottom-bar-height: 64px;
}

html, body {
  height: 100%;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

/* ── Nav bar — frosted glass ── */

.nav-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: rgba(242, 242, 247, 0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid var(--separator);
  flex-shrink: 0;
}

.nav-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  user-select: none;
}

/* ── Segmented control ── */

.segmented-wrap {
  padding: 12px 16px 8px;
  flex-shrink: 0;
}

.segmented-control {
  display: flex;
  background: var(--segmented-bg);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}

.segment {
  flex: 1;
  height: 32px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 0.18s var(--ease), box-shadow 0.18s var(--ease), color 0.18s;
  user-select: none;
}

.segment.selected {
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), 0 0.5px 1px rgba(0, 0, 0, 0.08);
  color: var(--text);
}

.segment:not(.selected):active {
  background: rgba(0, 0, 0, 0.05);
}

/* ── Main compose ── */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  padding-bottom: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom) + 8px);
  min-height: 0;
}

.compose-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-card);
  overflow: hidden;
  min-height: 0;
}

textarea {
  flex: 1;
  min-height: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.65;
  padding: 16px;
  resize: none;
  width: 100%;
}

textarea::placeholder {
  color: var(--text-tertiary);
  font-family: var(--font);
}

/* ── URL row ── */

.url-row {
  flex-shrink: 0;
  border-top: 0.5px solid var(--separator);
}

.url-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  width: 100%;
  padding: 0 16px;
  height: 46px;
  cursor: pointer;
  font-family: var(--font);
}

.url-toggle-label {
  font-size: 15px;
  color: var(--text-secondary);
}

.url-toggle-arrow {
  font-size: 19px;
  color: var(--text-tertiary);
  display: inline-block;
  transition: transform 0.2s var(--ease);
  line-height: 1;
}

.url-toggle-arrow.open {
  transform: rotate(90deg);
}

#url {
  display: block;
  background: transparent;
  border: none;
  border-top: 0.5px solid var(--separator);
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 12px 16px;
  width: 100%;
}

#url::placeholder {
  color: var(--text-tertiary);
}

/* ── Bottom bar — keyboard-hugging ── */

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 20px;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(242, 242, 247, 0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 0.5px solid var(--separator);
  will-change: transform;
  z-index: 20;
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s var(--ease), background 0.15s;
  flex-shrink: 0;
}

.send-btn:disabled {
  background: rgba(118, 118, 128, 0.2);
  cursor: default;
}

.send-btn:not(:disabled):active {
  opacity: 0.7;
  transform: scale(0.92);
}

.send-btn svg {
  display: block;
}

/* ── Toast ── */

.toast {
  position: fixed;
  bottom: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 100px;
  max-width: calc(100vw - 48px);
  text-align: center;
  z-index: 30;
  cursor: pointer;
  white-space: nowrap;
  background: rgba(50, 50, 52, 0.92);
  color: #fff;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: toast-in 0.25s var(--ease) both;
}

.toast.error {
  background: rgba(50, 50, 52, 0.92);
  color: #ff6b6b;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
