:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #050505;
  --muted: #5f5f5f;
  --line: #050505;
  --soft: #f2f2f2;
  --focus: #2458d3;
  --danger: #8a1f11;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.upload-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100svh;
}

.upload-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 10px 18px;
  border-bottom: 3px solid var(--line);
}

.brand-link {
  color: var(--ink);
  font-family: "Monaco", "Menlo", "Ubuntu Mono", "Consolas", monospace;
  font-weight: 700;
  text-decoration: none;
}

.session-status,
.section-label,
.meter-row,
.status-line {
  font-family: "Monaco", "Menlo", "Ubuntu Mono", "Consolas", monospace;
}

.session-status {
  max-width: 52vw;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capture-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  min-height: calc(100svh - 58px);
}

.composer {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  padding: 22px;
}

.section-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 62vh;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans Mono", "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 17px;
  line-height: 1.65;
}

textarea::placeholder {
  color: #8a8a8a;
}

.metadata-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border-left: 3px solid var(--line);
  background: var(--soft);
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.ttl-field legend {
  font-size: 13px;
  font-weight: 700;
}

input[type="text"] {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 0;
  padding: 11px 12px;
  background: var(--paper);
  color: var(--ink);
}

.ttl-field {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.ttl-field legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.ttl-field label {
  cursor: pointer;
}

.ttl-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ttl-field span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 2px solid var(--line);
  background: var(--paper);
  font-family: "Monaco", "Menlo", "Ubuntu Mono", "Consolas", monospace;
  font-weight: 700;
}

.ttl-field input:checked + span {
  background: var(--ink);
  color: var(--paper);
}

.meter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.meter-row[data-tone="error"] {
  color: var(--danger);
  font-weight: 700;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 2px solid var(--line);
  padding: 10px 14px;
  color: var(--ink);
  background: var(--paper);
  cursor: pointer;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.primary-action {
  background: var(--ink);
  color: var(--paper);
}

.secondary-action:hover,
.primary-action:hover {
  box-shadow: 4px 4px 0 var(--line);
  transform: translate(-2px, -2px);
}

.primary-action:disabled {
  opacity: 0.48;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.status-line {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.status-line[data-tone="error"] {
  color: var(--danger);
  font-weight: 700;
}

.auth-panel,
.receipt-panel {
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 20px;
  width: min(560px, calc(100vw - 36px));
  padding: 30px;
  border: 3px solid var(--line);
  background: var(--paper);
}

.auth-panel h1,
.receipt-panel h1 {
  margin: 0;
  font-size: clamp(28px, 8vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

.receipt-meta {
  margin: 12px 0 0;
  color: var(--muted);
}

.receipt-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

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

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .upload-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    min-height: 76px;
  }

  .session-status {
    max-width: 100%;
    text-align: left;
  }

  .capture-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .composer {
    min-height: 58svh;
    padding: 18px;
  }

  textarea {
    min-height: 50svh;
    font-size: 16px;
  }

  .metadata-panel {
    border-top: 3px solid var(--line);
    border-left: 0;
    padding: 18px;
  }

  .receipt-actions {
    grid-template-columns: 1fr;
  }
}
