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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-1);
  box-shadow: var(--shadow-1);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 10px 24px 8px;
}

.header-top {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
  padding-top: 2px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--fg-0);
}

.brand-sub {
  font-size: 10px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.page-tab {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--fg-2);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  text-decoration: none;
}

.page-tab:hover {
  color: var(--fg-0);
  background: var(--bg-2);
}

.page-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.header-external-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-ext-link {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border: none;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.header-ext-link:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.header-ext-link::after {
  content: '\2197';
  margin-left: 4px;
  font-size: 10px;
}

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

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

main#view {
  flex: 1;
  padding: 24px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
  background: var(--bg-1);
  border-top: 1px solid var(--border-1);
  font-size: 12px;
  color: var(--fg-2);
}


.footer-meta {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .app-header { flex-wrap: wrap; }
  .page-tabs { order: 3; flex-basis: 100%; }
  main#view { padding: 16px; }
  .app-footer { flex-wrap: wrap; gap: 8px; }
  .footer-meta { text-align: left; }
}
