:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --line: #d7dce0;
  --text: #182026;
  --muted: #60707c;
  --accent: #176b87;
  --accent-strong: #0f5166;
  --danger: #a7352a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-form {
  width: min(380px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-form p {
  color: var(--muted);
  margin-top: 4px;
}

.login-form .status {
  padding: 0;
  min-height: 20px;
}

.topbar {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: end;
  padding: 20px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

.topbar p,
.page-header p {
  color: var(--muted);
  margin-top: 4px;
}

.range {
  display: flex;
  gap: 12px;
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
}

input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
}

.upload-panel {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
}

.source-drop,
.attachment-drop {
  border: 1px dashed #9bacb6;
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
}

.source-drop {
  width: min(640px, 100%);
  min-height: 220px;
  font-size: 18px;
}

.attachment-drop {
  min-height: 112px;
}

.source-drop.dragover,
.attachment-drop.dragover {
  border-color: var(--accent);
  color: var(--accent);
}

.source-drop input,
.attachment-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.sidebar-header,
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.sidebar-header span {
  color: var(--muted);
}

.page-list {
  overflow: auto;
  padding: 8px;
}

.page-item {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.page-item.active {
  background: #e7f1f4;
  color: var(--accent-strong);
}

.badge {
  min-width: 24px;
  border-radius: 999px;
  padding: 2px 7px;
  background: #edf0f2;
  color: var(--muted);
  text-align: center;
}

.page-work {
  min-width: 0;
  min-height: 0;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.content-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 360px;
  gap: 16px;
}

iframe {
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.attachments {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.attachment-list {
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.attachment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.attachment-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove {
  background: transparent;
  color: var(--danger);
  padding: 4px 8px;
}

.status {
  min-height: 28px;
  padding: 0 24px 12px;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .topbar,
  .range,
  .content-grid {
    display: grid;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 220px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  iframe {
    min-height: 420px;
  }
}
