:root {
  color-scheme: light;
  --paper: #f7f5ee;
  --surface: #ffffff;
  --ink: #151515;
  --muted: #77736a;
  --line: #d6d1c5;
  --line-strong: #9b9588;
  --done: #19a35b;
  --working: #7a3ff2;
  --focus: #0f6b7a;
  --terminal: #080b0a;
  --terminal-ink: #d8eadb;
  font-family: Inter, "Avenir Next", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
  letter-spacing: 0;
  touch-action: pan-y;
}

body.pseudo-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.signin,
.home,
.code-view,
.files-view {
  width: 100%;
  min-height: 100%;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

.signin,
.home,
.code-view {
  display: grid;
  place-items: center;
}

.signin-form {
  width: min(340px, 100%);
  display: grid;
  gap: 12px;
}

.mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 700;
  justify-self: start;
}

.signin-form input,
.signin-form button {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
}

.signin-form input {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.signin-form button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
}

.app-grid {
  width: min(620px, 100%);
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 14px;
}

.app-icon {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 12px;
}

.app-icon > span:not(.app-badge) {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.app-icon strong {
  font-size: 14px;
  font-weight: 600;
}

.app-badge {
  position: absolute;
  top: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.app-badge-done {
  left: 8px;
  background: var(--done);
}

.app-badge-working {
  right: 8px;
  background: var(--working);
}

.agent-grid {
  width: min(620px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
}

.agent-add,
.agent-tile {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink);
}

.agent-add {
  min-height: 118px;
  border: 2px dotted var(--line-strong);
  display: grid;
  place-items: center;
  font-size: clamp(40px, 14vw, 72px);
  line-height: 1;
  font-weight: 300;
}

.agent-tile {
  min-height: 124px;
  border: 2px solid var(--ink);
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 10px;
  padding: 16px;
  text-align: left;
}

.agent-tile[data-status="working"] {
  border-color: var(--working);
}

.agent-tile[data-status="unchecked"] {
  border-color: var(--done);
}

.agent-tile strong {
  font-size: 15px;
  font-weight: 700;
}

.agent-tile span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.terminal-view {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: var(--terminal);
  color: var(--terminal-ink);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  overflow: hidden;
}

.terminal-output {
  --terminal-extra-top: 0px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: calc(14px + var(--terminal-extra-top)) 12px 8px;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.keyboard {
  display: grid;
  gap: 5px;
  min-height: 0;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(216, 234, 219, 0.16);
  background: #111513;
}

.key-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 5px;
}

.command-row {
  grid-auto-columns: minmax(0, 0.9fr);
}

.key {
  min-width: 0;
  height: 36px;
  border: 1px solid rgba(216, 234, 219, 0.18);
  border-radius: 7px;
  background: #1f2622;
  color: var(--terminal-ink);
  font-size: 13px;
  line-height: 1;
}

.key.wide {
  grid-column: span 2;
}

.keyboard[data-voice="1"] .key[data-role="voice"] {
  background: #d8eadb;
  color: #111513;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 12, 10, 0.18);
}

.modal-panel {
  width: min(320px, 100%);
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 8px;
}

.modal-options {
  display: grid;
  gap: 8px;
}

.modal-options button {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}

.modal-options button:disabled {
  color: var(--muted);
  background: #f0eee8;
}

.rename-form {
  display: grid;
  gap: 8px;
}

.rename-form input,
.rename-form button {
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
}

.rename-form input {
  border: 1px solid var(--line);
  padding: 0 12px;
}

.rename-form button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
  font-weight: 600;
}

.files-view {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.file-path {
  justify-self: center;
  max-width: min(86vw, 680px);
  min-height: 36px;
  display: grid;
  place-items: center;
  color: var(--ink);
  font: 13px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-list {
  width: min(760px, 100%);
  min-height: 0;
  justify-self: center;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.file-row {
  min-height: 54px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--ink);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  text-align: left;
}

.file-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  font-weight: 700;
}

.file-row[data-type="directory"] .file-mark {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

.file-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}

.edge-zone,
.dock-gesture-layer {
  position: fixed;
  top: 0;
  bottom: 0;
  background: transparent;
}

.edge-zone {
  right: 0;
  width: max(34px, env(safe-area-inset-right));
  z-index: 25;
  touch-action: none;
}

.dock-gesture-layer {
  inset: 0;
  z-index: 26;
  touch-action: none;
}

.dock {
  position: fixed;
  right: max(8px, env(safe-area-inset-right));
  top: 50%;
  z-index: 30;
  display: grid;
  gap: 8px;
  transform: translateY(-50%);
}

.dock button {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(21, 21, 21, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(21, 21, 21, 0.12);
}

#dock-fullscreen,
#dock-back {
  display: grid;
  place-items: center;
}

#dock-fullscreen::before {
  content: "";
  width: 18px;
  height: 18px;
  background:
    linear-gradient(currentColor 0 0) left top / 8px 2px no-repeat,
    linear-gradient(currentColor 0 0) left top / 2px 8px no-repeat,
    linear-gradient(currentColor 0 0) right top / 8px 2px no-repeat,
    linear-gradient(currentColor 0 0) right top / 2px 8px no-repeat,
    linear-gradient(currentColor 0 0) left bottom / 8px 2px no-repeat,
    linear-gradient(currentColor 0 0) left bottom / 2px 8px no-repeat,
    linear-gradient(currentColor 0 0) right bottom / 8px 2px no-repeat,
    linear-gradient(currentColor 0 0) right bottom / 2px 8px no-repeat;
}

#dock-back::before {
  content: "";
  width: 13px;
  height: 13px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateX(3px) rotate(45deg);
}

@media (max-width: 560px) {
  .app-grid {
    grid-template-columns: repeat(2, minmax(118px, 1fr));
  }
}

@media (min-width: 720px) {
  .terminal-output {
    font-size: 13px;
  }

  .keyboard {
    max-width: 760px;
    width: 100%;
    justify-self: center;
  }
}
