:root {
  color-scheme:light dark;
  --paper:#f6f8fa;
  --surface:#fff;
  --text:#172738;
  --muted:#526171;
  --line:#dce3e9;
  --blue:#175b9f;
  --coral:#b75239;
  --yellow:#d8a628;
  --light:#edf5ff;
  --green:#227052;
  --green-bg:#e7f5ed;
  --red:#a63e38;
  --red-bg:#fff0ed;
  --amber:#77520a;
  --amber-bg:#fff5d9;
}
* {
  box-sizing:border-box;
}
body {
  margin:0;
  background:var(--paper);
  color:var(--text);
  font:14px/1.65 -apple-system,BlinkMacSystemFont,"Hiragino Sans","Yu Gothic",Meiryo,sans-serif;
  font-feature-settings:normal;
  line-break:strict;
  word-break:normal;
  overflow-wrap:break-word;
}
button,input,select,textarea {
  font:inherit;
}
button {
  min-height:44px;
  padding:8px 16px;
  border:1px solid var(--line);
  border-radius:8px;
  background:var(--surface);
  color:var(--text);
  cursor:pointer;
  white-space:nowrap;
  font-weight:600;
}
button:hover {
  border-color:var(--blue);
  background:var(--light);
}
button:disabled {
  opacity:.5;
  cursor:wait;
}
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible {
  outline:3px solid var(--blue);
  outline-offset:3px;
}
button.primary {
  background:var(--blue);
  color:#fff;
  border-color:var(--blue);
}
button.quiet {
  border-color:transparent;
}
a {
  color:var(--blue);
  text-underline-offset:3px;
}
header {
  padding: 24px max(32px, calc((100% - 1176px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
}
.identity {
  display: flex;
  align-items: center;
  gap: 18px;
}
.appmark {
  display: inline-block;
  padding: 4px 0;
  color: var(--blue);
  border-bottom: 2px solid var(--yellow);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .16em;
}
h1 {
  font-size:19px;
  line-height:1.5;
  margin:0;
}
h2 {
  font-size:18px;
  margin:0;
  line-height:1.5;
}
h3 {
  font-size:16px;
  margin:0;
}
.identity p {
  font-size:12px;
  margin:0;
  color:var(--muted);
}
.header-actions {
  display:flex;
  align-items:center;
  gap:8px;
}
nav {
  padding: 0 max(32px, calc((100% - 1176px) / 2));
  display: flex;
  gap: 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
nav button {
  padding: 10px 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}
nav button:hover,
nav button[aria-pressed=true] {
  background: transparent;
  color: var(--blue);
  border-bottom-color: var(--blue);
}
#review-count {
  margin-left:4px;
}
main {
  max-width:1240px;
  margin:0 auto;
  padding:28px 32px 64px;
}
.section-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:20px;
  margin-bottom:20px;
}
.section-head p,.help {
  font-size:13px;
  color:var(--muted);
  margin:6px 0;
  line-height:1.8;
}
.small {
  font-weight:400;
  font-size:13px;
  color:var(--muted);
  margin-left:10px;
}
.compact {
  margin-top:28px;
}
.days {
  display:grid;
  gap:20px;
}
.day {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 18px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
}
.day.today .day-title h3 {
  color: var(--blue);
}
.day-title {
  display:flex;
  gap:10px;
  align-items:baseline;
  margin-bottom:12px;
}
.day-title h3 {
  font-size:17px;
}
.cards {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}
.cards > :only-child {
  grid-column: 1 / -1;
}
.post-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
}
.post-card.needs_review,
.post-card.error {
  border-inline-start: 3px solid var(--coral);
}
.post-head {
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:12px;
}
.post-head time {
  font-size:18px;
  font-weight:700;
}
.tag {
  display:inline-block;
  border-radius:16px;
  background:var(--light);
  color:var(--blue);
  padding:2px 10px;
  font-size:12px;
  font-weight:600;
}
.tag.scheduled,.tag.published {
  background:var(--green-bg);
  color:var(--green);
}
.tag.needs_review,.tag.error {
  background:var(--red-bg);
  color:var(--red);
}
.tag.draft {
  background:var(--amber-bg);
  color:var(--amber);
}
.post-card h4 {
  margin:0 0 8px;
  font-size:15px;
}
.caption {
  white-space:pre-wrap;
  margin:0 0 8px;
  font-size:14px;
  max-height:260px;
  overflow:auto;
}
.post-meta {
  font-size:12px;
  color:var(--muted);
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}
.post-actions {
  display:flex;
  gap:7px;
  flex-wrap:wrap;
  margin-top:14px;
}
.post-actions button {
  font-size:13px;
  padding:6px 12px;
}
.post-error {
  font-size:13px;
  color:var(--red);
  white-space:pre-wrap;
}
.empty {
  text-align:center;
  padding:64px 20px;
  border:1px dashed var(--line);
  border-radius:12px;
  background:var(--surface);
}
.empty h3 {
  margin-bottom:8px;
}
.empty p {
  color:var(--muted);
  font-size:14px;
  margin:8px auto;
  max-width:550px;
}
#notice {
  border-left:3px solid var(--blue);
  background:var(--surface);
  padding:12px 18px;
  margin-bottom:20px;
  font-size:14px;
  white-space:pre-wrap;
}
#notice.error {
  border-color:var(--red);
}
.filters {
  display:flex;
  gap:16px;
  align-items:end;
  flex-wrap:wrap;
  padding:16px;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:10px;
}
.filters label {
  margin:0;
  min-width:150px;
  font-size:12px;
}
.filters select,.filters input {
  min-height:44px;
}
.metric-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(155px,1fr));
  gap:10px;
  margin-top:16px;
}
.metric {
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:8px;
  padding:14px 16px;
}
.metric span {
  font-size:12px;
  color:var(--muted);
  display:block;
}
.metric strong {
  font-size:25px;
  line-height:1.5;
  display:block;
}
.metric small {
  font-size:11px;
  color:var(--muted);
}
.rank-grid {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:16px;
  margin:24px 0;
}
.rank {
  background:var(--surface);
  border:1px solid var(--line);
  padding:18px;
  border-radius:10px;
}
.rank h3 {
  margin-bottom:12px;
}
.rank ol {
  padding-left:28px;
  margin:0;
}
.rank li {
  padding:8px 0;
  border-bottom:1px solid var(--line);
  font-size:13px;
}
.rank li:last-child {
  border:0;
}
.rank li span {
  color:var(--muted);
}
.table-wrap {
  overflow:auto;
  border:1px solid var(--line);
  background:var(--surface);
  border-radius:10px;
}
table {
  width:100%;
  border-collapse:collapse;
  font-size:13px;
}
th,td {
  text-align:right;
  padding:12px;
  border-bottom:1px solid var(--line);
  white-space:nowrap;
}
th {
  background:var(--paper);
  font-weight:500;
  font-size:12px;
  color:var(--muted);
}
th:first-child,td:first-child {
  text-align:left;
  min-width:240px;
  max-width:360px;
  white-space:normal;
}
td:first-child small {
  display:block;
  color:var(--muted);
}
td:first-child a {
  display:block;
}
.inline {
  display:flex;
  gap:8px;
  align-items:center;
  font-size:13px;
  margin:0;
}
.inline select {
  width:auto;
}
.form-row {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
}
label {
  display:block;
  margin:16px 0 0;
  font-size:13px;
  font-weight:600;
}
input,select,textarea {
  display:block;
  width:100%;
  border:1px solid var(--line);
  border-radius:7px;
  padding:9px 12px;
  background:var(--surface);
  color:var(--text);
  min-height:44px;
  margin-top:5px;
}
textarea {
  resize:vertical;
  line-height:1.7;
}
label .help {
  font-weight:400;
  display:block;
}
dialog {
  width:min(760px,calc(100% - 32px));
  max-height:90vh;
  background:var(--surface);
  color:var(--text);
  border:1px solid var(--line);
  border-radius:14px;
  padding:24px;
  box-shadow:0 20px 90px #0003;
}
dialog::backdrop {
  background:#16273588;
}
.dialog-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
}
.dialog-actions {
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:22px;
}
pre {
  white-space:pre-wrap;
  background:var(--paper);
  border:1px solid var(--line);
  border-radius:8px;
  padding:16px;
  font-size:12px;
  max-height:330px;
  overflow:auto;
}
.error {
  color:var(--red);
}
dl {
  display:grid;
  grid-template-columns:130px 1fr;
  gap:10px;
  font-size:14px;
}
dt {
  color:var(--muted);
}
dd {
  margin:0;
}
#connection-details p {
  font-size:13px;
  color:var(--muted);
}
[hidden] {
  display:none!important;
}
@media(max-width:768px) {
  header {
    padding:18px 20px;
    align-items:flex-start;
    flex-wrap:wrap;
  }
  .header-actions {
    width:100%;
    justify-content:flex-end;
  }
  nav {
    padding:0 16px;
    gap:14px;
    overflow:auto;
  }
  nav button {
    padding:6px 2px;
  }
  main {
    padding:22px 18px 44px;
  }
  .section-head {
    align-items:flex-start;
  }
  .section-head p {
    max-width:400px;
  }
  .day {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .cards {
    grid-template-columns:1fr;
  }
  .rank-grid {
    grid-template-columns:1fr;
  }
  .filters label {
    flex:1;
  }
  .small {
    display:block;
    margin-left:0;
  }
  .form-row {
    grid-template-columns:1fr;
    gap:0;
  }
  .metric-grid {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  dialog {
    padding:20px;
  }
  dl {
    grid-template-columns:100px 1fr;
  }
  .section-head.compact {
    align-items:center;
  }
  .inline {
    flex-wrap:wrap;
  }
}
@media(prefers-color-scheme:dark) {
  :root {
    --paper:#172028;
    --surface:#202c36;
    --text:#e5edf3;
    --muted:#abbcc9;
    --line:#455662;
    --blue:#9ac6ff;
    --light:#243e5b;
    --coral:#ea9a83;
    --yellow:#e1bc5d;
    --green:#a0ddbd;
    --green-bg:#1a3c30;
    --red:#ffb7b1;
    --red-bg:#4a2826;
    --amber:#f2d17e;
    --amber-bg:#443b25;
  }
  button.primary {
    background:#1b61c9;
    color:white;
  }
}
@media(prefers-reduced-motion:reduce) {
  * {
    scroll-behavior:auto!important;
    animation:none!important;
    transition:none!important;
  }
}
.tag {
  white-space: nowrap;
}
@media (max-width: 768px) {
  .header-actions {
    flex-wrap: wrap;
  }
  .section-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .section-head > button {
    align-self: flex-start;
  }
  .section-head.compact {
    flex-direction: row;
    align-items: center;
  }
}
details {
  margin-top: 16px;
}
summary {
  cursor: pointer;
  min-height: 44px;
  padding: 8px 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-page { min-height:100vh; display:grid; place-items:center; padding:24px; }
.auth-card { width:min(100%,432px); margin:0; padding:38px; background:var(--surface,#fff); border:1px solid var(--line,#dce5ee); border-radius:6px; }
.auth-card h1 { margin-top:22px; font-size:26px; letter-spacing:-.02em; }
.auth-card form { display:grid; gap:18px; margin-top:28px; }
.auth-card label { display:grid; gap:8px; }
.auth-card button { width:100%; }
@media (max-width: 480px) {
  .auth-page { padding: 16px; }
  .auth-card { padding: 26px; }
  .identity { gap: 12px; }
}
[hidden] { display:none !important; }

.platform-switch {
  display: flex;
  gap: .5rem;
  padding: .75rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid #dce7f2;
  background: #f5faff;
}
.platform-switch button, .base-link { min-height: 44px; }
.platform-switch button[aria-pressed="true"] {
  color: #fff;
  background: #145790;
  border-color: #145790;
}
.base-link {
  display: inline-flex;
  align-items: center;
  padding: .55rem .8rem;
  border: 1px solid #afc8e0;
  border-radius: .5rem;
  color: #145790;
  font-weight: 650;
}
#threads-results td:first-child { min-width: 12rem; }
#threads-results details p { white-space: pre-wrap; overflow-wrap: anywhere; }

.threads-day {
  margin-block: 0 1rem;
  padding: .8rem;
  border: 1px solid #dce5ef;
  border-radius: .65rem;
  background: #fff;
}
.threads-day h3 { margin: 0 0 .6rem; }
.threads-day h3 span { font-size: .8rem; font-weight: 500; }
.threads-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.threads-card {
  padding: .65rem;
  border: 1px solid #d8e3ed;
  border-radius: .5rem;
  color: #172b40;
  background: #fbfcfe;
}
.threads-card--scheduled { background: #e9f6ee; border-color: #86b79a; }
.threads-card--stopped { background: #fff0ee; border-color: #e8a59a; }
.threads-card--published { background: #eef1f5; }
.threads-card .threads-card-heading {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}
.threads-status-badge {
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  background: #fff1cc;
  color: #644900;
}
.threads-card--scheduled .threads-status-badge { background: #176442; color: #fff; }
.threads-card--stopped .threads-status-badge { background: #992c20; color: #fff; }
.threads-card--published .threads-status-badge { background: #475569; color: #fff; }
.threads-fields { margin: .5rem 0 0; }
.threads-fields dt { margin-top: .55rem; font-size: .75rem; font-weight: 600; }
.threads-fields dd {
  margin: .2rem 0 0;
  padding: .4rem .55rem;
  border: 1px solid #dce5ef;
  border-radius: .3rem;
  background: #ffffffd9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.threads-top-post { padding: .65rem .8rem; border: 1px solid #dce5ef; border-radius: .5rem; background: #fff; }
@media (max-width: 640px) { .threads-slots { grid-template-columns: 1fr; } }
