:root {
  --bg: #101214;
  --panel: #181b1f;
  --panel-2: #20242a;
  --line: #303640;
  --text: #f6f1e8;
  --muted: #a8a095;
  --dim: #6f756f;
  --accent: #fdbe57;
  --accent-2: #6ee7b7;
  --blue: #8ab4f8;
  --red: #f87171;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", sans-serif;
  line-height: 1.5;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

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

.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 18, 20, 0.92);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}

.brand {
  min-width: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 28px 20px 42px;
  flex: 1;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.login-wrap {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-pad {
  padding: 20px;
}

.panel-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.kicker {
  margin-bottom: 6px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.lead {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.field {
  margin-bottom: 16px;
}

.label {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.hint {
  margin-top: 6px;
  color: var(--dim);
  font-size: 12px;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111418;
  color: var(--text);
  outline: none;
}

.input,
.select {
  height: 46px;
  padding: 0 13px;
}

.textarea {
  min-height: 108px;
  resize: vertical;
  padding: 12px 13px;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  padding: 7px 11px;
  font-size: 13px;
}

.chip.active {
  border-color: rgba(253, 190, 87, 0.75);
  color: var(--text);
  background: rgba(253, 190, 87, 0.12);
}

.btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #15120b;
}

.btn-secondary {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.btn-danger {
  background: transparent;
  border-color: rgba(248, 113, 113, 0.55);
  color: var(--red);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.status {
  margin-top: 12px;
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

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

.result-box,
.empty-box {
  min-height: 260px;
  padding: 20px;
  background: #111418;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}

.empty-box {
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.markdown {
  font-size: 15px;
}

.markdown .md-heading {
  margin-top: 18px;
  margin-bottom: 8px;
  color: var(--accent);
  font-weight: 800;
}

.markdown .md-bullet {
  padding-left: 16px;
  margin-bottom: 5px;
}

.markdown p {
  margin: 0 0 8px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.day-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.day-btn {
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.day-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-panel {
  min-height: calc(100vh - 130px);
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  min-height: 420px;
  max-height: calc(100vh - 280px);
  overflow-y: auto;
  padding: 18px;
}

.message {
  display: flex;
  margin-bottom: 12px;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(680px, 88%);
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.message.user .bubble {
  background: rgba(253, 190, 87, 0.14);
  border-color: rgba(253, 190, 87, 0.35);
}

.chat-compose {
  border-top: 1px solid var(--line);
  padding: 14px;
}

.compose-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.compose-row textarea {
  min-height: 46px;
  max-height: 140px;
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.small-note {
  color: var(--dim);
  font-size: 12px;
}

@media (max-width: 860px) {
  .tool-grid,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: 620px;
  }

  .chat-messages {
    max-height: 520px;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 0 14px;
  }

  .main {
    padding: 18px 12px 28px;
  }

  h1 {
    font-size: 24px;
  }

  .panel-pad,
  .panel-header,
  .result-box,
  .empty-box {
    padding: 16px;
  }

  .btn {
    width: 100%;
  }

  .top-actions .btn {
    width: auto;
  }

  .compose-row {
    align-items: stretch;
    flex-direction: column;
  }
}
