:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  font-synthesis: none;
  color: #1d1d1f;
  background: #f5f5f7;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #f5f5f7;
}

button, input, textarea, select { font: inherit; }
button, summary, select { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(22px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: -.03em;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: -.018em;
}

.app-header {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  min-height: 72px;
  padding: 0 4px 16px;
}

.app-name {
  margin-bottom: 3px;
  color: #6e6e73;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
}

.header-actions {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.header-button {
  min-width: 52px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: #0071e3;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.messages-card,
.settings-group {
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .035);
}

.settings-group { margin-bottom: 12px; }

.text-button, .quiet-button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: #0071e3;
  cursor: pointer;
}

.text-button {
  margin-right: -10px;
  padding: 0 10px;
  font-size: 15px;
  font-weight: 600;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.messages-card { min-height: calc(100dvh - 110px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.message-list:empty { display: none; }

.message-row {
  padding: 17px 20px 18px;
  border-bottom: 1px solid #e5e5e7;
}

.message-row:last-child { border-bottom: 0; }

.message-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.message-header strong {
  min-width: 0;
  font-size: 17px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.message-header time {
  margin-left: auto;
  color: #86868b;
  font-size: 13px;
  white-space: nowrap;
}

.message-row p {
  margin: 6px 0 0;
  color: #515154;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.empty-state {
  display: grid;
  min-height: calc(100dvh - 112px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  place-content: center;
  padding: 48px 24px;
  color: #86868b;
  text-align: center;
}

.empty-state p { margin-bottom: 0; font-size: 14px; line-height: 1.5; }
.empty-state .empty-title { margin-bottom: 7px; color: #1d1d1f; font-size: 18px; font-weight: 650; }

#status {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin: 0;
  padding-left: 20px;
}

#status dt, #status dd {
  min-height: 50px;
  padding: 14px 0;
  border-bottom: 1px solid #e5e5e7;
  font-size: 15px;
  line-height: 21px;
}

#status dt:last-of-type, #status dd:last-of-type { border-bottom: 0; }
#status dt { color: #1d1d1f; }

#status dd {
  margin: 0;
  padding-right: 20px;
  color: #6e6e73;
  text-align: right;
  overflow-wrap: anywhere;
}

.section-copy {
  margin: 0 0 20px;
  color: #6e6e73;
  font-size: 14px;
  line-height: 1.45;
}

label {
  display: block;
  margin: 0 0 7px;
  color: #6e6e73;
  font-size: 14px;
  font-weight: 500;
}

input, textarea, select {
  width: 100%;
  min-height: 48px;
  margin: 0 0 14px;
  padding: 11px 13px;
  border: 1px solid #d2d2d7;
  border-radius: 12px;
  outline: 0;
  background: #fff;
  color: #1d1d1f;
  font-size: 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus, textarea:focus, select:focus {
  border-color: #0071e3;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, .12);
}

textarea { min-height: 96px; resize: vertical; }
button { border-radius: 12px; }

.primary-button, .secondary-button {
  width: 100%;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 160ms ease, transform 80ms ease;
}

.primary-button { background: #0071e3; color: #fff; }
.primary-button:hover { background: #0077ed; }
.secondary-button { background: #f5f5f7; color: #1d1d1f; }
.secondary-button:hover { background: #e8e8ed; }
.primary-button:active, .secondary-button:active { transform: scale(.985); }

.quiet-button {
  display: block;
  margin: 10px auto -8px;
  padding: 0 12px;
  font-size: 14px;
}

.disclosure-card summary {
  display: flex;
  align-items: center;
  min-height: 66px;
  padding: 0 20px;
  font-size: 18px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

.disclosure-card summary::-webkit-details-marker { display: none; }

.disclosure-card summary::after {
  width: 9px;
  height: 9px;
  margin-left: auto;
  border-right: 2px solid #86868b;
  border-bottom: 2px solid #86868b;
  content: "";
  transform: rotate(45deg) translateY(-2px);
  transition: transform 160ms ease;
}

.disclosure-card[open] summary { border-bottom: 1px solid #e5e5e7; }
.disclosure-card[open] summary::after { transform: rotate(225deg) translate(-2px, -2px); }
.disclosure-content { padding: 20px; }
.status-content { padding: 0; }

.status-toolbar {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 20px;
  border-bottom: 1px solid #e5e5e7;
  color: #6e6e73;
  font-size: 13px;
  font-weight: 600;
}

.status-toolbar .text-button { margin-left: auto; }
.field-grid, .action-grid { display: grid; gap: 12px; }
.action-grid { margin-top: 6px; }

.event-panel {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e5e5e7;
}

.event-panel h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

#events {
  min-height: 92px;
  max-height: 320px;
  margin: 0;
  overflow: auto;
  padding: 16px;
  border-radius: 14px;
  background: #f5f5f7;
  color: #6e6e73;
  font: 12px/1.55 ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.privacy-note {
  margin: 24px auto 8px;
  color: #86868b;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

button:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(0, 113, 227, .28);
  outline-offset: 3px;
}

.settings-dialog {
  width: min(560px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 26px;
  background: #f5f5f7;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .24);
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, .35);
  backdrop-filter: blur(6px);
}

.settings-sheet {
  display: flex;
  max-height: calc(100dvh - 24px);
  flex-direction: column;
}

.settings-header {
  display: flex;
  align-items: center;
  min-height: 66px;
  padding: 0 14px 0 20px;
  border-bottom: 1px solid #d8d8dc;
  background: rgba(245, 245, 247, .94);
}

.settings-header h2 { font-size: 24px; }
.settings-header .header-button { margin-left: auto; }

.settings-scroll {
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (min-width: 620px) {
  .field-grid, .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 380px) {
  .app-shell { padding-right: 10px; padding-left: 10px; }
  #status dt, #status dd { font-size: 14px; }
}

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