:root {
  --paper: #fbf8f4;
  --surface: #fff;
  --surface-subtle: #f3eee7;
  --border: #e4dcd1;
  --text: #1f1b16;
  --muted: #5f574e;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-soft: #ffedd5;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --info: #0f766e;
  --radius-card: 10px;
  --radius-control: 8px;
  --shadow-soft: 0 1px 2px #1f1b160f, 0 6px 18px #1f1b160f;
  --space: 1rem;
  font-synthesis-weight: none;
  --lightningcss-light: initial;
  --lightningcss-dark: ;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

h1, h2, h3 {
  margin: 0 0 .5rem;
  font-weight: 600;
  line-height: 1.25;
}

h1 {
  font-size: 1.65rem;
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0 0 .75rem;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

code, kbd, pre {
  font-family: ui-monospace, Cascadia Code, Consolas, monospace;
}

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

.skip-link {
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-control);
  padding: .5rem .75rem;
  transition: top .12s;
  position: absolute;
  top: -3rem;
  left: .5rem;
}

.skip-link:focus {
  top: .5rem;
}

.shell-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  position: sticky;
  top: 0;
}

.shell-bar {
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  max-width: 76rem;
  margin: 0 auto;
  padding: .65rem 1rem;
  display: flex;
}

.brand {
  color: var(--text);
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
}

.brand-mark {
  color: var(--accent);
}

.brand-name {
  letter-spacing: .01em;
  font-size: 1.05rem;
}

.shell-nav {
  flex-wrap: wrap;
  flex: auto;
  align-items: center;
  gap: .75rem;
  display: flex;
}

.shell-nav a {
  color: var(--text);
  border-radius: var(--radius-control);
  padding: .35rem .55rem;
  text-decoration: none;
}

.shell-nav a:hover {
  background: var(--surface-subtle);
}

.shell-nav a.current {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.nav-workspaces {
  align-items: center;
  gap: .5rem;
  display: flex;
}

.nav-label {
  color: var(--muted);
  font-size: .85rem;
}

.nav-workspaces ul {
  flex-wrap: wrap;
  gap: .5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
}

.shell-account {
  align-items: center;
  gap: .5rem;
  margin-left: auto;
  display: flex;
}

.account-name {
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
  font-weight: 600;
  overflow: hidden;
}

.menu-toggle {
  display: none;
}

.shell-main {
  max-width: 76rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.shell-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  text-align: center;
  padding: 1rem;
  font-size: .9rem;
}

.live-region, .visually-hidden {
  clip-path: inset(50%);
  white-space: nowrap;
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
}

.page-header {
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  display: flex;
}

.page-actions {
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  display: flex;
}

.lead {
  color: var(--muted);
  max-width: 46rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  margin-bottom: 1rem;
  padding: 1.1rem;
}

.card-compact {
  padding: .75rem;
}

.card-title {
  margin-bottom: .35rem;
}

.card-subtitle {
  color: var(--muted);
  margin-bottom: .75rem;
}

.badge {
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--muted);
  border-radius: 999px;
  margin-right: .25rem;
  padding: .1rem .6rem;
  font-size: .78rem;
  display: inline-block;
}

.badge-accent {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: var(--accent-hover);
}

.badge-success {
  color: #14532d;
  background: #dcfce7;
  border-color: #dcfce7;
}

.badge-warning {
  color: #7c2d12;
  background: #fef3c7;
  border-color: #fef3c7;
}

.banner {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  border-left-width: 4px;
  margin-bottom: 1rem;
  padding: .75rem .9rem;
}

.banner-info {
  border-left-color: var(--info);
}

.banner-warning {
  border-left-color: var(--warning);
}

.banner-title {
  margin: 0;
  font-weight: 600;
}

.banner-body {
  margin-top: .35rem;
}

.empty {
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  background: var(--surface-subtle);
  padding: 1.75rem 1rem;
}

.empty-title {
  margin-bottom: .25rem;
  font-weight: 600;
}

.empty-body {
  color: var(--muted);
  max-width: 34rem;
  margin: 0 auto .75rem;
}

.empty-actions {
  justify-content: center;
  gap: .5rem;
  display: flex;
}

.loading {
  color: var(--muted);
  align-items: center;
  gap: .5rem;
  display: flex;
}

.dot {
  background: var(--accent);
  border-radius: 50%;
  width: .6rem;
  height: .6rem;
  display: inline-block;
}

.primary-button, .secondary-button, .danger-button, .ghost-button {
  font: inherit;
  border-radius: var(--radius-control);
  cursor: pointer;
  border: 1px solid #0000;
  padding: .5rem .9rem;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

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

.secondary-button {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

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

.danger-button {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 600;
}

:is(.primary-button, .secondary-button, .danger-button, .ghost-button):disabled {
  opacity: .55;
  cursor: not-allowed;
}

.secondary-link {
  color: var(--accent);
  align-self: center;
}

.field {
  margin-bottom: .85rem;
}

.field label {
  margin-bottom: .25rem;
  font-weight: 600;
  display: block;
}

select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  width: 100%;
  max-width: 34rem;
  padding: .5rem .65rem;
}

input[type="text"] {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  width: 100%;
  max-width: 34rem;
  padding: .5rem .65rem;
}

input[type="search"] {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  width: 100%;
  max-width: 34rem;
  padding: .5rem .65rem;
}

input[type="email"] {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  width: 100%;
  max-width: 34rem;
  padding: .5rem .65rem;
}

input[type="password"] {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  width: 100%;
  max-width: 34rem;
  padding: .5rem .65rem;
}

textarea {
  resize: vertical;
}

.hint {
  color: var(--muted);
  margin: .25rem 0 0;
  font-size: .88rem;
}

.muted {
  color: var(--muted);
}

.tab-bar {
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: .25rem;
  margin-bottom: 1rem;
  display: flex;
}

.tab-bar button {
  font: inherit;
  cursor: pointer;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid #0000;
  padding: .5rem .75rem;
}

.tab-bar button.active {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-panel[hidden] {
  display: none;
}

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  margin-bottom: 1rem;
  padding: 1.25rem;
}

.hero-actions {
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: .5rem;
  display: flex;
}

.project-list, .template-grid, .plain-list, .version-list, .setting-list, .message-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.project-list li + li, .plain-list li + li, .version-list li + li, .setting-list li + li {
  border-top: 1px solid var(--border);
}

.project-link {
  color: var(--text);
  padding: .7rem 0;
  text-decoration: none;
  display: block;
}

.project-name {
  font-weight: 600;
  display: block;
}

.project-meta, .version-meta, .activity-summary + .version-meta {
  color: var(--muted);
  font-size: .88rem;
  display: block;
}

.project-description {
  color: var(--muted);
  margin-top: .2rem;
  font-size: .92rem;
  display: block;
}

.template-grid {
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: .85rem;
  display: grid;
}

.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.template-card a {
  color: var(--text);
  padding: .9rem;
  text-decoration: none;
  display: block;
}

.template-name {
  font-weight: 600;
  display: block;
}

.template-summary {
  color: var(--muted);
  margin: .2rem 0 .5rem;
  font-size: .92rem;
  display: block;
}

.template-tags {
  flex-wrap: wrap;
  gap: .25rem;
  display: flex;
}

.template-shot {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  max-width: 100%;
  margin-bottom: .75rem;
}

.gallery-toolbar {
  margin-bottom: 1rem;
}

.version-bar {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  margin-bottom: 1rem;
  padding: .6rem .8rem;
}

.version-current {
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  display: flex;
}

.version-message {
  font-weight: 600;
}

.version-list li, .setting-list li {
  padding: .6rem 0;
}

.setting-row {
  grid-template-columns: minmax(9rem, 14rem) 1fr auto;
  align-items: center;
  gap: .5rem;
  display: grid;
}

.stat-grid {
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: .75rem;
  margin: 0 0 .75rem;
  display: grid;
}

.stat-grid dt {
  color: var(--muted);
  font-size: .85rem;
}

.stat-grid dd {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
}

.table {
  border-collapse: collapse;
  width: 100%;
  display: block;
  overflow-x: auto;
}

.table th, .table td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  padding: .55rem .5rem;
}

.table th {
  color: var(--muted);
  font-size: .85rem;
  font-weight: 600;
}

.member-name {
  font-weight: 600;
  display: block;
}

.member-email {
  color: var(--muted);
  font-size: .85rem;
  display: block;
}

.table select {
  width: auto;
  margin-right: .35rem;
  display: inline-block;
}

.usage-amount {
  margin-right: .35rem;
  font-weight: 600;
}

.chat {
  gap: .75rem;
  display: grid;
}

.chat-log {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  min-height: 12rem;
  max-height: 60vh;
  padding: .9rem;
  overflow-y: auto;
}

.message {
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  margin-bottom: .6rem;
  padding: .6rem .75rem;
}

.message-forge {
  background: var(--surface);
  border-left: 3px solid var(--accent);
}

.message-head {
  align-items: baseline;
  gap: .5rem;
  margin: 0 0 .2rem;
  display: flex;
}

.message-author {
  font-weight: 600;
}

.message-time {
  color: var(--muted);
  font-size: .82rem;
}

.message-body {
  white-space: pre-wrap;
  margin: 0;
}

.chat-composer {
  justify-items: start;
  gap: .5rem;
  display: grid;
}

.signin {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  text-align: center;
  max-width: 34rem;
  margin: 2rem auto;
  padding: 1.5rem;
}

.signin .brand-mark {
  width: 44px;
  height: 44px;
}

@media (width <= 640px) {
  .shell-bar {
    align-items: flex-start;
  }

  .menu-toggle {
    margin-left: auto;
    display: inline-block;
  }

  .shell-nav {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    display: none;
  }

  .shell-nav.open {
    display: flex;
  }

  .shell-account {
    justify-content: space-between;
    width: 100%;
    margin-left: 0;
  }

  .chat-log {
    max-height: none;
  }

  .setting-row {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, :before, :after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
