* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  --tn-bg: #fffbeb;
  --tn-surface: #ffffff;
  --tn-text: #1c1917;
  --tn-muted: #78716c;
  --tn-accent: #d97706;
  --tn-accent-ink: #ffffff;
  --tn-danger: #b91c1c;
  --tn-border: rgba(180, 83, 9, 0.16);
  --tn-banner: #b45309;
  --tn-font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --tn-touch: 44px;
  --tn-safe-top: env(safe-area-inset-top, 0px);
  --tn-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tn-safe-left: env(safe-area-inset-left, 0px);
  --tn-safe-right: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --tn-bg: #1c1917;
    --tn-surface: #292524;
    --tn-text: #fafaf9;
    --tn-muted: #d6d3d1;
    --tn-accent: #f59e0b;
    --tn-accent-ink: #1c1917;
    --tn-danger: #f87171;
    --tn-border: rgba(251, 191, 36, 0.18);
    --tn-banner: #292524;
  }
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--tn-font);
  font-size: 16px;
  line-height: 1.45;
  background: var(--tn-bg);
  color: var(--tn-text);
  color-scheme: light dark;
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(64px + var(--tn-safe-bottom));
}

.tn-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--tn-banner);
  color: #fff;
  padding-top: var(--tn-safe-top);
}

.tn-banner-inner,
.tn-main {
  width: min(720px, 100%);
  margin: 0 auto;
}

.tn-banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px calc(16px + var(--tn-safe-right)) 10px calc(16px + var(--tn-safe-left));
}

.tn-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tn-brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.tn-brand strong,
.tn-meta {
  display: block;
}

.tn-meta {
  font-size: 12px;
  opacity: 0.86;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 52vw;
}

.tn-main {
  flex: 1;
  padding: 16px;
  padding-left: calc(16px + var(--tn-safe-left));
  padding-right: calc(16px + var(--tn-safe-right));
  display: grid;
  gap: 16px;
  align-content: start;
}

.tn-card,
.tn-row {
  background: var(--tn-surface);
  border: 1px solid var(--tn-border);
  border-radius: 16px;
}

.tn-composer,
.tn-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.tn-composer h2,
.tn-toolbar h2,
.tn-card h3 {
  margin: 0;
  font-size: 18px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--tn-muted);
}

input,
select,
button,
textarea {
  font: inherit;
}

input,
select {
  min-height: var(--tn-touch);
  width: 100%;
  border: 1px solid var(--tn-border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--tn-bg);
  color: var(--tn-text);
}

input[type="color"] {
  padding: 4px;
  height: var(--tn-touch);
}

.tn-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn {
  min-height: var(--tn-touch);
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.btn-primary {
  background: var(--tn-accent);
  color: var(--tn-accent-ink);
  font-weight: 650;
}

.btn-ghost {
  border: 1px solid var(--tn-border);
}

.btn-danger {
  color: var(--tn-danger);
}

.btn-compact {
  min-height: 36px;
  padding: 0 10px;
  font-size: 14px;
}

.tn-status,
.tn-empty,
.tn-meta {
  color: var(--tn-muted);
}

.tn-status,
.tn-empty {
  margin: 0;
}

.tn-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tn-toolbar input,
.tn-toolbar select {
  max-width: 180px;
}

.tn-list,
.tn-bars,
.tn-stats-grid {
  display: grid;
  gap: 10px;
}

.tn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.tn-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}

.tn-row-body {
  min-width: 0;
  flex: 1;
  display: grid;
}

.tn-row-body span,
.tn-row-body small {
  color: var(--tn-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tn-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.tn-stats-grid {
  grid-template-columns: 1fr;
}

.tn-stat span {
  color: var(--tn-muted);
  font-size: 13px;
}

.tn-stat strong {
  font-size: 22px;
}

.tn-bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.tn-bar-meta span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tn-bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--tn-border);
  overflow: hidden;
}

.tn-bar-fill {
  height: 100%;
  border-radius: inherit;
}

.tn-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--tn-surface);
  border-top: 1px solid var(--tn-border);
  padding-bottom: var(--tn-safe-bottom);
}

.tn-bottom-link {
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  color: var(--tn-muted);
}

.tn-bottom-link.active {
  color: var(--tn-accent);
  font-weight: 650;
}

@media (min-width: 640px) {
  .tn-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
