:root {
  --bg: #12110e;
  --fg: #e8e0d4;
  --muted: #8a8070;
  --line: #2c281f;
  --amber: #c47b16;
  --fail: #b54a3a;
  --ok: #6b8f4e;
  --panel: #1a1814;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  border-top: 2px solid var(--amber);
}

#app {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 20px calc(40px + env(safe-area-inset-bottom, 0px));
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}

.ledger-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.08em;
  color: var(--amber);
}

h2 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: none;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.banner {
  margin: 0;
  color: var(--fail);
  font-size: 13px;
}

.logout {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 8px 0;
}

.logout:hover,
.logout:focus {
  color: var(--amber);
}

.ledger-nav {
  display: flex;
  gap: 14px;
  font-size: 13px;
}

.ledger-nav a {
  color: var(--muted);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.ledger-nav a[aria-current='page'],
.ledger-nav a:hover,
.ledger-nav a:focus {
  color: var(--amber);
}

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-empty {
  padding: 16px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
}

.history-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 12px 16px;
}

.history-status {
  margin: 0 0 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
}

.history-item dl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px 16px;
  margin: 0;
}

.meta,
.login-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 12px 16px;
  margin-bottom: 20px;
}

dl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px 20px;
  margin: 0;
}

dl .wide {
  grid-column: 1 / -1;
}

dt {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

dd {
  margin: 2px 0 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
}

dd[data-kind='running'],
dd[data-kind='queued'] {
  color: var(--amber);
}

dd[data-kind='success'] {
  color: var(--ok);
}

dd[data-kind='failed'] {
  color: var(--fail);
}

section {
  margin-bottom: 22px;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
}

.steps li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.steps li:last-child {
  border-bottom: 0;
}

.steps .step-label {
  color: var(--fg);
}

.steps .step-state {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.steps li[data-state='running'] .step-state {
  color: var(--amber);
}

.steps li[data-state='done'] .step-state {
  color: var(--ok);
}

.steps li[data-state='failed'] .step-state {
  color: var(--fail);
}

.steps .empty {
  padding: 10px 12px;
  color: var(--muted);
}

.log-follow {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ok);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.log-follow[data-paused='1'] {
  color: var(--amber);
}

.tail {
  margin: 0;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--fg);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: min(52dvh, 28rem);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

body.login {
  display: flex;
  align-items: stretch;
}

.login-app {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100dvh - 2px);
  max-width: 420px;
  width: 100%;
}

.login-desc {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.login-app .banner {
  margin-bottom: 12px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.login-field span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.login-field input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  line-height: 1.4;
  outline: none;
  -webkit-appearance: none;
}

.login-field input:focus {
  border-color: var(--amber);
}

.ledger-btn {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--amber);
  border-radius: 2px;
  background: transparent;
  color: var(--amber);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.ledger-btn:active {
  background: #c47b1622;
}

@media (max-width: 640px) {
  #app {
    padding-top: 16px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }

  h1 {
    font-size: 18px;
  }

  .ledger-head {
    flex-wrap: wrap;
    margin-bottom: 16px;
  }

  .banner {
    flex-basis: 100%;
    order: 3;
  }

  dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .steps li {
    min-height: 44px;
    align-items: center;
    padding: 12px;
  }

  .tail {
    max-height: min(58dvh, 24rem);
  }
}
