:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  line-height: 1.4;
  font-size: 16px;
  --bg-primary: #ffffff;
  --bg-secondary: #f0f2f5;
  --bg-tertiary: #ffffff;
  --border-color: #e4e6eb;
  --text-primary: #15589b;
  --text-secondary: #65676b;
  --text-tertiary: #1c1e21;
  --accent-primary: #15589b;
  --accent-hover: #114982;
  --accent-pressed: #060630;
  background: var(--bg-primary);
  color: var(--text-primary);
}

:root.dark {
  --bg-primary: #18191a;
  --bg-secondary: #242526;
  --bg-tertiary: #242526;
  --border-color: #3e4042;
  --text-primary: #e4e6eb;
  --text-secondary: #b0b3b8;
  --text-tertiary: #e4e6eb;
  --accent-primary: #4d4dff;
  --accent-hover: #6b6bff;
  --accent-pressed: #3333ff;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
}

.app {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  padding: 2.5rem;
  gap: 2rem;
}

.app__header h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.app__header p {
  margin: 0.2rem 0 0;
  color: var(--text-secondary);
}

.app__content {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 2.5rem;
  align-items: flex-start;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field-group label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-tertiary);
  letter-spacing: -0.01em;
}

.field-group input,
.field-group textarea,
.field-group select {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.75rem 0.875rem;
  font: inherit;
  font-size: 0.9375rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border 0.15s ease;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.field-group textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.5;
}

.field-group input[type="file"] {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.field-group input[type="file"]::file-selector-button {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  margin-right: 0.75rem;
  transition: background 0.15s ease;
}

.field-group input[type="file"]::file-selector-button:hover {
  background: var(--border-color);
}

.field-group--inline {
  flex-direction: row;
  align-items: center;
  gap: 1rem;
}

.field-group-row {
  display: flex;
  gap: 0.75rem;
}

.field-group-row .field-group {
  flex: 0 1 auto;
  min-width: 0;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--text-tertiary);
  cursor: pointer;
}

.checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.metrics {
  border: 1px solid var(--border-color);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.metrics legend {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-tertiary);
  padding: 0 0.4rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}

.metrics .metric {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.metrics label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-tertiary);
  letter-spacing: -0.01em;
}

.metrics input[type="number"] {
  padding: 0.75rem 0.875rem;
  font-size: 0.9375rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.preview-panel {
  background: var(--bg-tertiary);
  padding: 2.5rem;
  display: flex;
  gap: 1.5rem;
  border: 1px solid var(--border-color);
  flex-direction: column;
  align-items: center;
}

.tweet {
  width: 680px;
  max-width: 100%;
  border-radius: 12px;
  padding: 2rem;
  background: #fff;
  color: #0f1419;
  font-size: 1rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border: 1px solid #e1e8ed;
}

.tweet--dark {
  background: #15202b;
  color: #e7e9ea;
}

.tweet__header {
  display: flex;
  gap: 1rem;
}

.tweet__avatar-wrapper {
  flex: 0 0 auto;
  width: 80px;
  height: 80px;
  border-radius: 999px;
  overflow: hidden;
}

.tweet__avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tweet__identity {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
}

.tweet__display-name {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.tweet__badge {
  width: 26px;
  height: 26px;
  fill: var(--accent-primary);
}

.tweet--dark .tweet__badge {
  fill: var(--accent-primary);
}

.tweet__handle {
  color: #536471;
  font-weight: 500;
  font-size: 1.0625rem;
}

.tweet--dark .tweet__handle {
  color: #8b98a5;
}

.tweet__body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 1.8rem;
  padding: 4rem 0 4rem 0;
}

.tweet__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  color: #536471;
  font-size: 0.95rem;
}

.tweet--dark .tweet__meta {
  color: #8b98a5;
}

.tweet__dot {
  font-weight: 700;
}

.tweet__divider {
  height: 1px;
  background: #e1e8ed;
}

.tweet--dark .tweet__divider {
  background: rgba(56, 68, 77, 0.7);
}

.tweet__metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.95rem;
  color: #536471;
}

.tweet--dark .tweet__metrics {
  color: #8b98a5;
}

.tweet__metrics span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.tweet__metric-icon {
  width: 1.125rem;
  height: 1.125rem;
  fill: currentColor;
}

.tweet__metrics strong {
  color: inherit;
}

.export-panel {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  align-content: center;
}

.button {
  border: none;
  border-radius: 4px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  font-size: 0.9375rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease;
}

.button:not(.button--ghost) {
  background: var(--accent-primary);
  color: #fff;
}

.button:not(.button--ghost):hover {
  background: var(--accent-hover);
}

.button:not(.button--ghost):active {
  background: var(--accent-pressed);
}

.button--ghost {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.button--ghost:hover {
  background: var(--border-color);
}

#status-message {
  min-height: 1.2rem;
  font-size: 0.9rem;
  color: #1a7f37;
}

.app__footer {
  text-align: center;
  color: var(--text-secondary);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .app {
    padding: 1.5rem;
  }

  .app__content {
    grid-template-columns: 1fr;
  }

  .control-panel {
    order: 2;
  }
}

/* Theme toggle button */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: background 0.15s;
}

.theme-toggle:hover {
  background: var(--bg-secondary);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  color: var(--text-primary);
}

.theme-toggle .light-icon {
  display: none;
}

.theme-toggle .dark-icon {
  display: block;
}

:root.dark .theme-toggle .light-icon {
  display: block;
}

:root.dark .theme-toggle .dark-icon {
  display: none;
}

/* Page Navigation (for internal pages) */
.page-nav {
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-nav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-nav-brand {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.page-nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.page-nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s;
}

.page-nav-links a:hover {
  color: var(--accent-primary);
}

.page-nav-links a.active {
  color: var(--text-primary);
  font-weight: 600;
}

/* Dropdown navigation styles */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-family: inherit;
}

.nav-dropdown-toggle:hover {
  color: var(--accent-primary);
}

.nav-dropdown-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s;
}

.nav-dropdown.active .nav-dropdown-toggle svg {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  min-width: 180px;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.nav-dropdown.active .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.2s;
}

.nav-dropdown-menu a:hover {
  background: var(--bg-secondary);
}

.nav-dropdown-menu a.active {
  color: var(--accent-primary);
  font-weight: 600;
}

@media (max-width: 768px) {
  .nav-dropdown-menu {
    left: auto;
    right: 0;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg-primary: #18191a;
    --bg-secondary: #242526;
    --bg-tertiary: #242526;
    --border-color: #3e4042;
    --text-primary: #e4e6eb;
    --text-secondary: #b0b3b8;
    --text-tertiary: #e4e6eb;
    --accent-primary: #4d4dff;
    --accent-hover: #6b6bff;
    --accent-pressed: #3333ff;
  }

  .tweet--light {
    background: #fff;
    color: #0f1419;
  }
}
