:root {
  color-scheme: light;
  --paper: #f4f2ee;
  --panel: #fbfaf8;
  --card: #ffffff;
  --ink: #242321;
  --muted: #77736e;
  --line: #e4e1dc;
  --green: #2f7d52;
  --claude: #bd6849;
  --codex: #292929;
}

* { box-sizing: border-box; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; }
.hidden { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
}

.task-sidebar {
  display: flex;
  min-height: calc(100vh - 20px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.compact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 13px 10px;
  border-bottom: 1px solid var(--line);
}

.compact-header h1 {
  font-size: 21px;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.compact-header p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.machine-state {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-size: 11px;
  font-weight: 650;
}

.machine-state.offline { color: #a64e45; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin: 8px 9px 7px;
  padding: 2px;
  border-radius: 9px;
  background: #ece9e4;
}

.tab {
  min-height: 30px;
  padding: 5px 8px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.tab.active { color: var(--ink); background: #fff; font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.06); }

.task-scroll {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.task-section { margin: 0; }
.recent-section { margin-top: 4px; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 29px;
  padding: 5px 12px 4px;
  color: var(--muted);
}

.section-heading h2 { font-size: 11px; font-weight: 700; }
.section-heading span { font-size: 10px; }
.task-list { display: flex; flex-direction: column; }

.task-card {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 67px;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.task-card:hover { background: #f1efeb; }
.task-card:active { background: #eae7e2; }
.task-card.is-selected { background: #e9e6e1; }
.task-card.is-active::before { position: absolute; inset: 9px auto 9px 0; width: 3px; border-radius: 0 4px 4px 0; background: var(--green); content: ""; }
.task-card:focus-visible { outline: 2px solid rgba(189,104,73,.4); outline-offset: -2px; }

.provider-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.claude-mark { background: var(--claude); }
.codex-mark { background: var(--codex); }
.task-content { min-width: 0; }

.task-card h3 {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-card p {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta { display: flex; gap: 7px; min-width: 0; margin-top: 3px; color: #9a958e; font-size: 9px; }
.task-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 3px 6px;
  border-radius: 6px;
  color: var(--muted);
  background: #edeae5;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.status-executing, .status-thinking, .status-verifying { color: #276845; background: #dfeee5; }
.status-failed { color: #9d4039; background: #f6e3df; }
.status-waiting_confirmation { color: #8b621b; background: #f4e8ce; }

.empty-state { margin: 18px 10px; padding: 22px 12px; border: 1px dashed #d4d0ca; border-radius: 10px; color: var(--muted); font-size: 13px; text-align: center; }
.empty-state small { display: block; margin-top: 5px; font-size: 10px; }

footer { display: flex; justify-content: space-between; padding: 8px 11px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }

.pairing-body { display: grid; min-height: 100vh; padding: 22px; place-items: center; }
.pairing-card { width: min(100%,430px); padding: 26px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 12px 34px rgba(0,0,0,.07); }
.eyebrow { margin-bottom: 7px; color: var(--claude); font-size: 12px; font-weight: 700; letter-spacing: .12em; }
.pairing-card h1 { font-size: 28px; }
.pairing-card p { margin-top: 12px; color: var(--muted); line-height: 1.65; }
.pairing-card button { width: 100%; margin: 22px 0 12px; padding: 12px 16px; border: 0; border-radius: 11px; color: #fff; background: var(--ink); font-weight: 700; }
.pairing-card small { color: var(--muted); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; clip-path: inset(50%); }

body.conversation-open { height: 100dvh; min-height: 0; overflow: hidden; }
body.conversation-open .shell { position: fixed; inset: 0; width: min(100%, 1280px); height: 100dvh; min-height: 0; padding: max(6px,env(safe-area-inset-top)) 6px max(6px,env(safe-area-inset-bottom)); }

.conversation-view { position: relative; display: flex; height: 100%; min-height: 0; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.conversation-header { display: flex; flex: none; align-items: center; gap: 9px; min-height: 58px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fff; }
.back-button { display: grid; width: 34px; height: 34px; flex: none; padding: 0 0 2px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; place-items: center; font-size: 25px; line-height: 1; cursor: pointer; }
.conversation-heading { min-width: 0; }
.conversation-provider { margin-bottom: 1px; color: var(--codex); font-size: 9px; font-weight: 800; }
.conversation-provider.claude { color: var(--claude); }
.conversation-heading h1 { overflow: hidden; max-width: 100%; font-size: 15px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.conversation-subtitle { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--muted); font-size: 9px; }
.conversation-connection { flex: none; padding: 5px 10px; border-bottom: 1px solid var(--line); color: var(--muted); background: #f2f0ec; font-size: 10px; text-align: center; }

.conversation-messages { display: flex; min-height: 0; flex: 1; flex-direction: column; gap: 8px; overflow-y: auto; padding: 12px 10px 16px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.conversation-empty { position: absolute; top: 48%; left: 50%; width: min(80%,320px); color: var(--muted); font-size: 12px; text-align: center; transform: translate(-50%,-50%); pointer-events: none; }
.conversation-entry { width: fit-content; max-width: min(92%,760px); padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px 12px 12px 4px; background: #fff; }
.conversation-entry.entry-user { align-self: flex-end; border-color: #30302f; border-radius: 12px 12px 4px 12px; color: #fff; background: #30302f; }
.conversation-entry.entry-progress { align-self: center; max-width: 94%; padding: 4px 8px; border: 0; border-radius: 999px; color: var(--muted); background: #ebe8e3; font-size: 10px; text-align: center; }
.entry-text { overflow-wrap: anywhere; font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.entry-text a { color: #1267a9; font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }
.entry-text .local-file-link::before { margin-right: 3px; content: "📎"; }
.entry-user .entry-text a { color: #bfe0ff; }
.conversation-entry small { display: block; margin-top: 4px; color: #978d83; font-size: 9px; }
.entry-user small { color: #cfc9c2; }

.conversation-composer { display: grid; flex: none; grid-template-columns: auto minmax(0,1fr) auto; gap: 6px; padding: 8px 8px max(8px,env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; }
.conversation-composer textarea { width: 100%; min-height: 40px; max-height: 120px; resize: none; padding: 9px 10px; border: 1px solid #d8d4ce; border-radius: 10px; color: var(--ink); background: #fff; font: inherit; font-size: 16px; line-height: 1.35; outline: none; }
.conversation-composer textarea:focus { border-color: rgba(189,104,73,.6); box-shadow: 0 0 0 2px rgba(189,104,73,.1); }
.conversation-composer .send-button { align-self: end; min-width: 58px; height: 40px; padding: 0 12px; border: 0; border-radius: 10px; color: #fff; background: var(--claude); font-weight: 750; cursor: pointer; }
.conversation-composer .attachment-button { display: grid; width: 40px; height: 40px; align-self: end; padding: 0 0 2px; border: 1px solid #d8d4ce; border-radius: 10px; color: var(--ink); background: #f2f0ec; place-items: center; font-size: 24px; line-height: 1; cursor: pointer; }
.conversation-composer .send-button:disabled, .conversation-composer .attachment-button:disabled, .conversation-composer textarea:disabled { opacity: .48; cursor: not-allowed; }
.attachment-list { display: flex; grid-column: 1/-1; flex-wrap: wrap; gap: 5px; }
.attachment-chip { display: inline-flex; max-width: 100%; align-items: center; gap: 5px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: #f5f3ef; font-size: 10px; }
.attachment-chip span { overflow: hidden; max-width: 240px; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip button { padding: 0; border: 0; color: #9d4039; background: transparent; font-size: 15px; line-height: 1; }
.delivery-status { grid-column: 1/-1; min-height: 13px; color: var(--muted); font-size: 10px; text-align: center; }

@media (min-width: 860px) {
  .shell { width: min(100%, 1080px); }
  body.conversation-open .shell { display: grid; grid-template-columns: 318px minmax(0,1fr); gap: 7px; }
  body.conversation-open #task-list-view.hidden { display: flex !important; }
  body.conversation-open .task-sidebar { min-height: 0; height: 100%; }
  .conversation-view { border-radius: 14px; }
  .conversation-header .back-button { display: none; }
  .conversation-entry { max-width: min(82%,800px); }
}

@media (max-width: 859px) {
  body.conversation-open .shell { width: 100%; }
  .task-sidebar { min-height: calc(100dvh - max(20px,env(safe-area-inset-top) + env(safe-area-inset-bottom))); }
}

@media (max-width: 420px) {
  .shell { padding-inline: 5px; }
  .task-sidebar, .conversation-view { border-radius: 13px; }
  .conversation-heading h1 { max-width: calc(100vw - 92px); }
}
