:root {
  --accent: #0078d7;
  --accent-light: #2196f3;
  --bg: #1f1f1f;
  --bg-alt: #252525;
  --bg-panel: #2b2b2b;
  --border: #3a3a3a;
  --border-soft: #333;
  --text: #ffffff;
  --text-secondary: #b3b3b3;
  --error: #e81123;
  --radius-panel: 8px;
  --shadow-elevated: 0 2px 8px rgba(0, 0, 0, 0.4);
  --header-height: 52px;
  --footer-height: 52px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --transition-fast: 0.15s ease-out;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

#app-root {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  padding-top: calc(var(--header-height) + var(--safe-top));
  padding-bottom: calc(var(--footer-height) + var(--safe-bottom));
}

/* Header */

.app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  width: 100%;
  height: calc(var(--header-height) + var(--safe-top));
  padding-top: var(--safe-top);
  background: rgba(31, 31, 31, 0.96);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 12px;
  z-index: 10;
}

.header-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-title {
  font-size: 15px;
  font-weight: 600;
}

.app-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.8;
}

.header-right {
  display: flex;
  gap: 6px;
}

/* Footer / command bar */

.app-footer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  width: 100%;
  height: calc(var(--footer-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(23, 23, 23, 0.98);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.command-bar {
  display: flex;
  width: 100%;
  justify-content: space-around;
  padding-inline: 4px;
}

.command-item {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  flex: 1;
  padding-block: 4px;
  border-radius: 4px;
}

.command-item:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

.command-item.active {
  color: var(--accent-light);
}

.cmd-icon {
  font-family: "Segoe MDL2 Assets";
  font-size: 16px;
}

/* Main */

.app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 8px 0;
  gap: 8px;
  overflow: hidden;
}

/* Buttons */

.command-button,
.accent-button {
  appearance: none;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
  background: #333;
  color: var(--text);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  min-height: 28px;
}

.command-button.primary {
  border-color: var(--accent-light);
}

.accent-button {
  background: var(--accent);
  border-color: var(--accent-light);
}

.command-button:disabled,
.accent-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.command-button:focus-visible,
.accent-button:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 1px;
}

/* Panels */

.status-panel,
.compose-panel,
.timeline-panel {
  background: var(--bg-panel);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-elevated);
  border: 1px solid var(--border-soft);
  padding: 10px;
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-body.center {
  align-items: center;
  justify-content: center;
  min-height: 80px;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
}

.panel-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.status-panel.error {
  border-color: var(--error);
}

.error-text {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 11px;
  margin: 0;
  white-space: pre-wrap;
}

/* Identity */

.identity-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.identity-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #444;
  flex: 0 0 auto;
  overflow: hidden;
}

.identity-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.identity-meta {
  min-width: 0;
}

.identity-display {
  font-size: 13px;
  font-weight: 600;
}

.identity-handle {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Compose */

.compose-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compose-input {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
  background: #202020;
  color: var(--text);
  padding: 6px 8px;
  font-size: 13px;
  resize: none;
  min-height: 70px;
}

.compose-input:focus-visible {
  outline: 1px solid var(--accent-light);
  outline-offset: 0;
}

.compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.compose-counter {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Timeline */

.timeline-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.timeline-title {
  font-size: 13px;
  font-weight: 600;
}

.timeline-actions {
  display: flex;
  gap: 4px;
}

.timeline-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  margin-right: -4px;
}

/* Status actions */

.status-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
}

.status-action-button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 2px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.status-action-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.status-action-button:focus-visible {
  outline: 1px solid var(--accent-light);
  outline-offset: 1px;
}

/* Compose media */

.compose-media-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.compose-media-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

.compose-media-preview {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  max-width: 60%;
}

.compose-media-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  flex: 0 0 auto;
  background: #444;
}

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

.compose-reply-indicator {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

/* Profile editor */

.profile-editor {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.profile-input,
.profile-textarea {
  border-radius: 4px;
  border: 1px solid var(--border-soft);
  background: #202020;
  color: var(--text);
  padding: 4px 6px;
  font-size: 12px;
}

.profile-textarea {
  resize: vertical;
  min-height: 60px;
}

.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-avatar-upload-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.profile-status {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Status item */

.status-item {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.status-item:last-child {
  border-bottom: none;
}

.status-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 auto;
  background: #444;
}

.status-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.status-main {
  min-width: 0;
}

.status-header {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}

.status-author {
  min-width: 0;
}

.status-display {
  font-size: 13px;
  font-weight: 600;
}

.status-handle {
  font-size: 11px;
  color: var(--text-secondary);
}

.status-meta {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-content {
  font-size: 13px;
  line-height: 1.35;
  word-wrap: break-word;
}

.status-content p {
  margin: 0.15em 0;
}

.status-content a {
  color: var(--accent-light);
  text-decoration: none;
}

.status-content a:hover {
  text-decoration: underline;
}

/* Progress ring */

.progress-ring {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-light);
  animation: spin 0.8s linear infinite;
}

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

/* Hidden utility */

[hidden] {
  display: none !important;
}

/* Small screens tweaks */

@media (max-width: 360px) {
  .app-header {
    padding-inline: 8px;
  }

  .command-button,
  .accent-button {
    padding-inline: 6px;
  }

  .app-main {
    padding-inline: 6px;
  }
}