:root {
  color-scheme: light;
  --bg: #f3f7f5;
  --surface: #fff;
  --line: #d7e3de;
  --text: #18352e;
  --muted: #687d75;
  --primary: #176d59;
  --primary-soft: #e3f2ec;
  --blue: #2d6f9b;
  --blue-soft: #e7f1f7;
  --purple: #775092;
  --purple-soft: #f0e9f5;
  --amber: #9a620b;
  --amber-soft: #fff1d8;
  --red: #9a4038;
  --red-soft: #fae8e6;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: max(13px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
}
.eyebrow { margin: 0 0 3px; color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .08em; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: 1.15rem; }
h2 { margin: 0; font-size: 1.15rem; }
h3 { margin: 0; font-size: .95rem; }
.staff-box { text-align: right; }
.staff-box span { display: block; color: var(--muted); font-size: .62rem; }
.staff-box strong { display: block; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .76rem; }
.subtext { margin: 4px 0 0; color: var(--muted); font-size: .74rem; }

.connection-banner { margin: 10px 12px 0; padding: 11px 13px; border: 1px solid #e2bc68; border-radius: 12px; background: #fff7df; color: #6e4a00; font-size: .76rem; line-height: 1.6; }
.connection-banner strong { display: block; margin-bottom: 2px; }
.connection-banner.is-error { border-color: #d69a94; background: var(--red-soft); color: #772d28; }

main { width: min(100%, 1120px); margin: 0 auto; padding: 16px 12px calc(88px + env(safe-area-inset-bottom)); }
.screen { min-width: 0; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.icon-button, .secondary-button { min-height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); padding: 0 11px; font-weight: 800; font-size: .72rem; cursor: pointer; }
.primary-button { min-height: 43px; border: 0; border-radius: 11px; background: var(--primary); color: #fff; padding: 0 15px; font-weight: 900; cursor: pointer; }
.primary-button:disabled { background: #c9d7d2; color: #60756e; cursor: default; }
.sticky-action { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); width: 100%; margin-top: 14px; box-shadow: 0 9px 24px rgba(18,75,60,.22); }

.period-panel { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.period-panel summary { padding: 11px 13px; color: var(--primary); font-size: .76rem; font-weight: 900; cursor: pointer; }
.period-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 0 12px 12px; }
.period-fields label, .category-form label, #attention-form label, .search-field { color: var(--muted); font-size: .72rem; font-weight: 800; }
.period-fields input, .category-form input, #attention-form input, #attention-form textarea, .search-field input, .classify-select {
  width: 100%; min-height: 42px; margin-top: 5px; border: 1px solid #c9d8d2; border-radius: 10px; background: #fff; color: var(--text); padding: 9px 10px;
}
.period-fields .secondary-button { grid-column: 1 / -1; }

.filter-row, .horizontal-selector { display: flex; gap: 7px; overflow-x: auto; padding: 1px 1px 5px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar, .horizontal-selector::-webkit-scrollbar { display: none; }
.filter-chip, .selector-chip { flex: 0 0 auto; min-height: 34px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: #50675f; padding: 0 11px; font-size: .72rem; font-weight: 800; cursor: pointer; }
.filter-chip.is-active, .selector-chip.is-active { border-color: var(--primary); background: var(--primary); color: #fff; }

.feed-list, .card-list, .timeline, .category-list { display: grid; gap: 9px; margin-top: 8px; }
.feed-card, .attention-card, .timeline-card, .category-row, .classify-source {
  position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 13px 13px 12px 16px;
}
.feed-card::before, .attention-card::before, .timeline-card::before, .classify-source::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--primary); }
.feed-card.is-work::before { background: var(--blue); }
.feed-card.is-operation::before { background: var(--purple); }
.feed-card.is-unknown::before, .classify-source::before { background: var(--amber); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.card-head strong { font-size: .84rem; }
.status-tag, .count-badge { display: inline-flex; align-items: center; min-height: 22px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); padding: 3px 8px; font-size: .64rem; font-weight: 900; }
.status-tag.is-work { background: var(--blue-soft); color: var(--blue); }
.status-tag.is-operation { background: var(--purple-soft); color: var(--purple); }
.status-tag.is-unknown { background: var(--amber-soft); color: var(--amber); }
.feed-card p, .attention-card p, .timeline-card p, .classify-source p { margin: 7px 0 6px; font-size: .79rem; line-height: 1.65; }
.card-meta { color: var(--muted); font-size: .67rem; line-height: 1.55; }
.card-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.text-button, .outline-button, .danger-button { min-height: 34px; border-radius: 9px; padding: 0 10px; font-size: .7rem; font-weight: 900; cursor: pointer; }
.text-button { border: 0; background: transparent; color: var(--primary); padding-left: 0; }
.outline-button { border: 1px solid #a9cbbf; background: #f8fbfa; color: var(--primary); }
.danger-button { border: 1px solid #ddb3af; background: var(--red-soft); color: var(--red); }

.empty-state { border: 1px dashed #bdcec7; border-radius: 14px; padding: 28px 16px; text-align: center; color: var(--muted); background: rgba(255,255,255,.45); }
.empty-state strong { display: block; color: #416158; font-size: .86rem; }
.empty-state p { margin: 6px 0 0; font-size: .74rem; line-height: 1.6; }

.person-attention { margin-top: 12px; }
.person-attention .attention-card { background: #fff8e9; border-color: #e3c47f; }
.timeline-card { padding-left: 16px; }
.search-field { display: block; margin-bottom: 10px; }
.search-field input { margin-top: 6px; }

.category-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.category-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; }
.category-row.is-inactive { opacity: .58; }
.category-name strong { display: block; font-size: .8rem; }
.category-name span { color: var(--muted); font-size: .67rem; }
.category-actions { display: flex; gap: 5px; }
.category-actions button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); cursor: pointer; }

.classify-panel { display: grid; gap: 12px; }
.classify-step { padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.classify-step h3 { margin-bottom: 9px; }
.classify-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.classify-type { min-height: 42px; border: 1px solid #c9d9d3; border-radius: 10px; background: #fff; color: var(--text); font-weight: 900; font-size: .74rem; cursor: pointer; }
.classify-type.is-active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.classify-select { margin: 0; }
.queue-navigation { display: flex; justify-content: space-between; gap: 8px; }
.queue-navigation button { flex: 1; }

.bottom-nav {
  position: fixed; inset: auto 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); min-height: 65px;
  padding: 7px 3px max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); backdrop-filter: blur(12px);
}
.nav-button { position: relative; min-width: 0; border: 0; background: transparent; color: #74877f; padding: 2px 1px; font-size: .63rem; font-weight: 900; line-height: 1.3; cursor: pointer; }
.nav-button > span { display: block; margin-bottom: 2px; font-size: 1rem; }
.nav-button.is-active { color: var(--primary); }
.nav-badge { position: absolute; top: -2px; right: 14%; display: grid; place-items: center; min-width: 17px; height: 17px; border-radius: 999px; background: #bd6426; color: #fff; font-size: .6rem; font-style: normal; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; align-items: end; background: rgba(11,31,25,.48); }
.modal { width: 100%; max-height: 88vh; overflow-y: auto; border-radius: 20px 20px 0 0; background: #fff; padding: 17px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -16px 44px rgba(0,0,0,.18); }
.modal-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: .7rem; }
.close-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--text); font-size: 1.2rem; cursor: pointer; }
.raw-message { white-space: pre-wrap; }
#attention-form { display: grid; gap: 11px; }
#attention-form textarea { resize: vertical; }

.loading { position: fixed; inset: 0; z-index: 80; display: grid; place-content: center; justify-items: center; background: rgba(243,247,245,.78); color: var(--primary); font-size: .78rem; font-weight: 900; }
.loading span { width: 34px; height: 34px; border: 4px solid #c8ddd5; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.toast { position: fixed; left: 14px; right: 14px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 90; transform: translateY(12px); opacity: 0; pointer-events: none; border-radius: 11px; background: #153a32; color: #fff; padding: 11px 13px; text-align: center; font-size: .74rem; font-weight: 900; transition: .2s ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 760px) {
  main { padding: 22px 20px 110px; }
  .app-header { padding-inline: max(24px, calc((100vw - 1080px) / 2)); }
  .bottom-nav { left: 50%; bottom: 14px; width: 650px; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 12px 34px rgba(25,67,55,.16); }
  .feed-list, .card-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky-action { width: min(420px, 100%); margin-left: auto; margin-right: auto; }
  .modal-backdrop { align-items: center; justify-items: center; }
  .modal { width: min(560px, calc(100% - 32px)); border-radius: 20px; }
}

@media (max-width: 360px) {
  main { padding-inline: 9px; }
  .nav-button { font-size: .59rem; }
  .period-fields { grid-template-columns: 1fr; }
  .period-fields .secondary-button { grid-column: auto; }
}
