@font-face {
  font-family: "Noto Sans JP";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/noto-sans-jp.woff2") format("woff2");
}
@font-face {
  font-family: "SignalBox Emoji";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/emoji-fallback.woff") format("woff");
}
:root {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  color-scheme: light dark;
  --bg: #fff;
  --text: #182338;
  --surface: #f7f9fc;
  --surface-2: #eef2f7;
  --blue: #2563eb;
  --accent-soft: #e9f0ff;
  --accent-text: #164bc4;
  --row-selected: #f1f6ff;
  --line: #e6eaf0;
  --input-line: #ccd4e0;
  --muted: #69758a;
  --strong: #263850;
  --code-bg: #f4f6fa;
  --urgent-bg: #fff0e8;
  --urgent-text: #a24b1e;
  --ok-bg: #e8f6ee;
  --ok-text: #246346;
  --danger: #b32b33;
  --focus: #93b4ff;
  --toast-bg: #182338;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1520;
    --text: #e6ebf3;
    --surface: #151d2b;
    --surface-2: #1e2838;
    --blue: #3b82f6;
    --accent-soft: #1c2c4d;
    --accent-text: #a9c6ff;
    --row-selected: #17243d;
    --line: #263246;
    --input-line: #34425a;
    --muted: #98a3b6;
    --strong: #e6ebf3;
    --code-bg: #1a2333;
    --urgent-bg: #3a2014;
    --urgent-text: #ffb38a;
    --ok-bg: #173226;
    --ok-text: #8fdcb1;
    --danger: #ff8a8f;
    --focus: #5b8cff;
    --toast-bg: #2a3548;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: 10px 15px;
  background: var(--surface-2);
  color: inherit;
  min-height: 42px;
}
button:hover {
  filter: brightness(0.96);
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
button:disabled {
  opacity: 0.55;
  cursor: default;
}
input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--input-line);
  border-radius: 8px;
  padding: 11px;
  background: var(--bg);
  color: inherit;
}
label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin: 16px 0 8px;
}
label input,
label textarea,
label select {
  display: block;
  margin-top: 7px;
}
h1 {
  font-size: 1.6rem;
  letter-spacing: -0.025em;
  margin: 4px 0 0;
}
h2 {
  font-size: 1.2rem;
  margin: 0 0 20px;
}
p {
  line-height: 1.7;
}
.primary {
  background: var(--blue);
  color: #fff;
}
.subtle {
  background: transparent;
  border: 1px solid var(--line);
}
.danger {
  color: var(--danger);
}
.muted {
  color: var(--muted);
  font-size: 0.875rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
}
.brand-icon {
  background: var(--blue);
  color: white;
  border-radius: 9px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
}
.login {
  max-width: 400px;
  margin: 10vh auto;
  padding: 24px;
}
.login h1 {
  margin: 32px 0 24px;
}
.login form > .primary {
  width: 100%;
  margin: 20px 0;
}
summary {
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
}
.workspace {
  display: grid;
  grid-template-columns: 245px 1fr;
  min-height: 100vh;
}
aside {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 25px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
aside .brand {
  margin: 0 10px 35px;
}
.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: transparent;
  width: 100%;
  font-size: 0.925rem;
  padding: 12px;
  justify-content: space-between;
}
.nav.selected {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.sidebar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 12px 5px;
  color: var(--muted);
  font-size: 0.8rem;
}
.icon-button {
  padding: 2px 8px;
  background: transparent;
  font-size: 1.4rem;
  min-height: 30px;
}
.project-nav {
  justify-content: flex-start;
}
.project-letter {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--blue);
  color: white;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.project-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-bottom {
  margin-top: auto;
  padding-top: 40px;
}
.email {
  padding: 15px 12px;
  overflow-wrap: anywhere;
}
.count {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--blue);
  color: #fff;
  padding: 2px 7px;
  border-radius: 10px;
}
.count:empty {
  display: none;
}
main {
  min-width: 0;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 29px 32px;
  border-bottom: 1px solid var(--line);
  gap: 16px;
}
.eyebrow {
  font-size: 0.8rem;
  color: var(--muted);
}
.header-actions {
  display: flex;
  gap: 18px;
  align-items: center;
}
#connection {
  white-space: nowrap;
}
#connection::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  background: var(--muted);
}
#connection[data-state="ok"]::before {
  background: #22a06b;
}
#connection[data-state="error"]::before {
  background: var(--danger);
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
}
.tabs {
  display: flex;
  gap: 4px;
}
.tab {
  font-size: 0.875rem;
  background: transparent;
  padding: 8px 12px;
  white-space: nowrap;
}
.tab.selected {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.search {
  margin: 0 0 0 auto;
  max-width: 240px;
  font-weight: 400;
  min-width: 80px;
}
.search input {
  margin: 0;
  font-size: 0.875rem;
}
.toolbar > .subtle {
  font-size: 0.875rem;
  white-space: nowrap;
}
#local-state-filter {
  width: 132px;
  margin: 0;
  font-size: 0.875rem;
  flex-shrink: 0;
}
.local-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 0.8rem;
}
.state-badge,
.scope-label {
  border-radius: 5px;
  padding: 3px 7px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.75rem;
}
.state-badge.done {
  background: var(--ok-bg);
  color: var(--ok-text);
}
.personal-section {
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding-top: 24px;
}
.personal-heading,
.note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.personal-heading h3 {
  margin: 0;
  font-size: 1rem;
}
.scope-label {
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 20px 0;
}
.emoji-button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1.2rem;
  background: var(--surface-2);
  border: 1px solid transparent;
  font-family:
    "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
    "SignalBox Emoji", sans-serif;
}
.local-summary > span:first-child {
  font-family:
    "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
    "SignalBox Emoji", sans-serif;
}
.emoji-button[aria-pressed="true"] {
  border-color: var(--blue);
  background: var(--accent-soft);
}
.personal-state {
  max-width: 200px;
}
#personal-note {
  resize: vertical;
  min-height: 108px;
}
.note-footer {
  margin-top: 10px;
}
.inbox-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.95fr) minmax(300px, 1.1fr);
  height: calc(100vh - 185px);
}
.message-list {
  overflow-y: auto;
  border-right: 1px solid var(--line);
}
.list-group {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  padding: 9px 25px 7px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.list-group span {
  font-weight: 400;
}
.list-group.urgent {
  color: var(--urgent-text);
  background: var(--urgent-bg);
}
.message-row {
  width: 100%;
  border-radius: 0;
  background: var(--bg);
  text-align: left;
  padding: 18px 25px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.message-row:hover {
  filter: none;
  background: var(--surface);
}
.message-row.selected {
  background: var(--row-selected);
  box-shadow: inset 3px 0 0 var(--blue);
}
.row-main {
  display: block;
  flex: 1;
  min-width: 0;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}
.hue-0 {
  background: #2563eb;
}
.hue-1 {
  background: #7c3aed;
}
.hue-2 {
  background: #db2777;
}
.hue-3 {
  background: #c2410c;
}
.hue-4 {
  background: #15803d;
}
.hue-5 {
  background: #0e7490;
}
.hue-6 {
  background: #a16207;
}
.hue-7 {
  background: #475569;
}
.row-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.row-flags {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.message-row.unread .row-meta > span:first-child {
  color: var(--text);
  font-weight: 600;
}
.row-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.row-title {
  font-weight: 400;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.message-row.unread .row-title {
  font-weight: 700;
}
.row-body {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 3px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  margin-right: 7px;
  vertical-align: 1px;
}
.starred-symbol {
  color: #d99a00;
}
.badge {
  font-size: 0.72rem;
  border-radius: 5px;
  padding: 3px 6px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.urgent {
  background: var(--urgent-bg);
  color: var(--urgent-text);
  font-weight: 600;
}
.detail {
  padding: 32px;
  overflow-y: auto;
}
.detail-placeholder,
.empty {
  padding: 70px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.925rem;
  line-height: 1.8;
}
.empty strong {
  display: block;
  color: var(--strong);
  font-size: 1rem;
  margin-bottom: 8px;
}
.empty .subtle {
  display: block;
  margin: 18px auto 0;
}
.kbd-hint {
  font-size: 0.8rem;
  margin-top: 18px;
}
kbd {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 3px;
  background: var(--surface);
}
.detail h2 {
  font-size: 1.5rem;
  line-height: 1.5;
  margin: 16px 0 20px;
  overflow-wrap: anywhere;
}
.detail-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.9;
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 25px 0;
}
.detail img {
  display: block;
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
  border-radius: 10px;
  margin-top: 18px;
}
.detail-link {
  display: inline-block;
  word-break: break-all;
  color: var(--accent-text);
  text-decoration: none;
  padding: 10px 0;
}
.detail-link:hover {
  text-decoration: underline;
}
.detail-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}
.detail-meta .avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 0.75rem;
}
.receipt-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 18px;
  margin: 0 0 22px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.875rem;
}
.receipt-card.waiting {
  background: var(--urgent-bg);
  border-color: transparent;
  color: var(--urgent-text);
}
.receipt-card div {
  display: grid;
  gap: 4px;
  flex: 1;
  min-width: 200px;
}
/* A question sits below the body it asks about; open questions use the accent. */
.question-card {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  margin: 0 0 22px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.875rem;
}
.question-card.open {
  background: var(--accent-soft);
  border-color: transparent;
}
.question-card > div:first-child {
  display: grid;
  gap: 4px;
}
.question-card .answers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.question-card textarea {
  width: 100%;
  resize: vertical;
}
.question-card #send-answer {
  justify-self: start;
}
.settings {
  max-width: 760px;
  padding: 28px 32px;
}
.settings-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 22px;
}
.settings-card h2 {
  margin-bottom: 10px;
}
.form-row {
  display: flex;
  gap: 16px;
}
.form-row > label {
  flex: 1;
}
.device-row,
.log-row {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.device-row:last-child {
  border: 0;
}
.code {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  background: var(--code-bg);
  padding: 12px;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  width: min(520px, calc(100vw - 32px));
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 70px #15274930;
  background: var(--bg);
  color: var(--text);
}
dialog::backdrop {
  background: #17283e60;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 25px;
}
#toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: white;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 5px 25px #0002;
  z-index: 10;
  max-width: 90vw;
  display: flex;
  align-items: center;
  gap: 16px;
}
.toast-action {
  background: transparent;
  color: #9cc0ff;
  font-weight: 600;
  padding: 4px 6px;
  min-height: 32px;
  white-space: nowrap;
}
#login-error {
  color: var(--danger);
  font-size: 0.9rem;
}
.sr-only {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  width: 1px;
  height: 1px;
  overflow: hidden;
}
[hidden] {
  display: none !important;
}
.usage-track {
  height: 5px;
  border-radius: 5px;
  background: var(--surface-2);
  margin: 15px 0;
}
.usage-track span {
  display: block;
  height: 100%;
  background: var(--blue);
  border-radius: 5px;
}
.usage-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
}
.project-setting {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 16px 0;
}
.project-setting select {
  max-width: 160px;
}
.project-setting > span {
  flex: 1;
}
@media (max-width: 900px) {
  .toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .workspace {
    grid-template-columns: 190px 1fr;
  }
  header {
    padding: 24px;
  }
  .inbox-layout {
    grid-template-columns: 1fr;
  }
  .detail {
    display: none;
  }
  .detail.mobile-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 5;
    background: var(--bg);
  }
  .message-list {
    border: 0;
  }
  .header-actions #connection {
    display: none;
  }
  .kbd-hint {
    display: none;
  }
}
@media (max-width: 600px) {
  .workspace {
    display: block;
  }
  aside {
    padding: 14px 16px;
    display: block;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  aside .brand {
    margin: 0 0 12px;
  }
  .sidebar-label,
  .sidebar-bottom .email {
    display: none;
  }
  aside > .nav {
    display: inline-flex;
    width: auto;
  }
  #projects {
    display: flex;
    overflow-x: auto;
    gap: 5px;
    margin-top: 5px;
  }
  #projects .nav {
    width: auto;
    max-width: 180px;
    padding: 8px;
    font-size: 0.8rem;
  }
  .sidebar-bottom {
    padding: 0;
    position: absolute;
    top: 14px;
    right: 12px;
    display: flex;
  }
  .sidebar-bottom .nav {
    font-size: 0.8rem;
    width: auto;
    padding: 8px;
  }
  header {
    padding: 22px 18px;
  }
  h1 {
    font-size: 1.35rem;
  }
  .primary {
    font-size: 0.875rem;
  }
  .toolbar {
    padding: 12px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .search {
    order: 2;
    width: 100%;
    max-width: none;
  }
  .toolbar > .subtle {
    margin-left: auto;
  }
  #mark-all-read {
    display: none;
  }
  .inbox-layout {
    height: auto;
    min-height: 50vh;
  }
  .message-row {
    padding: 16px;
    gap: 12px;
  }
  .list-group {
    padding: 8px 16px 6px;
  }
  .settings {
    padding: 20px 16px;
  }
  .settings-card {
    padding: 20px;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .header-actions {
    gap: 0;
  }
  .detail {
    padding: 24px;
  }
  .detail.mobile-open {
    padding-top: 24px;
  }
  /* Eight equal columns keep the picker on one row at phone widths. */
  .emoji-picker {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
  .emoji-button {
    width: auto;
  }
}

#close-detail {
  display: none;
}
@media (max-width: 900px) {
  #close-detail {
    display: block;
    margin-bottom: 20px;
  }
  body:has(.detail.mobile-open) {
    overflow: hidden;
  }
}
@media (max-width: 600px) {
  aside {
    position: relative;
  }
  .sidebar-label {
    display: flex;
    font-size: 0;
    margin: 0;
    position: absolute;
    right: 12px;
    top: 74px;
  }
  .sidebar-label button {
    font-size: 1.2rem;
  }
  #projects {
    padding-right: 44px;
  }
}
