:root {
  color-scheme: light;
  --ink: #121827;
  --muted: #5b6879;
  --line: rgba(33, 48, 70, 0.16);
  --panel: rgba(255, 255, 255, 0.82);
  --glass: rgba(255, 255, 255, 0.66);
  --blue: #2f86ff;
  --pink: #ed51b9;
  --orange: #ff7a1a;
  --green: #11a875;
  --shadow: 0 24px 70px rgba(16, 24, 38, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Inter", "PingFang TC", "Microsoft JhengHei", "Microsoft YaHei", Arial, sans-serif;
  background:
    linear-gradient(90deg, rgba(238, 246, 242, 0.96), rgba(242, 246, 252, 0.8)),
    url("/hero-bg.jpg") center top / cover fixed no-repeat;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(1500px, calc(100% - 28px));
  margin: 0 auto;
  padding: 14px 0 30px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: grid;
  grid-template-columns: 260px 1fr auto;
  align-items: center;
  gap: 18px;
  min-height: 66px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 14px 42px rgba(16, 24, 38, 0.12);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 19px;
  line-height: 1.1;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.workspace-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.workspace-tabs a,
.notice-button,
.wallet-button,
.login-button,
.small-button,
.new-chat-button,
.send-button,
.upload-button,
.portal-card,
.wallet-card button {
  border-radius: 8px;
  font-weight: 900;
}

.workspace-tabs a {
  padding: 10px 14px;
  color: #213044;
  border: 1px solid transparent;
}

.workspace-tabs a.is-active,
.workspace-tabs a:hover {
  color: #fff;
  background: linear-gradient(90deg, var(--blue), var(--pink));
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.notice-button,
.wallet-button,
.login-button,
.small-button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: #182334;
  padding: 0 12px;
  cursor: pointer;
}

.wallet-button {
  color: #07855b;
  background: rgba(218, 248, 232, 0.9);
}

.login-button,
.send-button,
.new-chat-button {
  color: #fff;
  border: 0;
  background: linear-gradient(90deg, var(--orange), var(--pink));
}

.portal-view {
  min-height: calc(100vh - 96px);
  display: grid;
  align-content: center;
  gap: 26px;
}

.portal-hero p {
  margin: 0 0 10px;
  color: #f06413;
  font-weight: 900;
}

.portal-hero h1 {
  width: min(860px, 100%);
  margin: 0;
  font-size: 58px;
  line-height: 1.02;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.portal-card {
  display: grid;
  min-height: 240px;
  gap: 14px;
  align-content: start;
  padding: 24px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  transition: transform 160ms ease, border-color 160ms ease;
}

.portal-card:hover {
  transform: translateY(-3px);
  border-color: rgba(47, 134, 255, 0.56);
}

.portal-card span {
  display: grid;
  width: 54px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  font-weight: 900;
}

.portal-card strong {
  font-size: 22px;
}

.portal-card small {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
  font-weight: 800;
}

.workspace-view {
  display: grid;
  grid-template-columns: 260px 360px minmax(0, 1fr);
  gap: 12px;
  height: calc(100vh - 104px);
  margin-top: 14px;
}

.history-column,
.control-column,
.chat-column {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.history-column {
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.history-header {
  display: grid;
  gap: 10px;
}

.new-chat-button,
.send-button {
  min-height: 44px;
  cursor: pointer;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  overflow: auto;
  padding-right: 4px;
}

.history-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(35, 50, 72, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  text-align: left;
}

.history-item.is-active {
  border-color: rgba(47, 134, 255, 0.54);
  box-shadow: inset 3px 0 0 var(--blue);
}

.history-item strong {
  overflow: hidden;
  color: #182334;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.control-column {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 12px;
}

.control-card {
  border: 1px solid rgba(35, 50, 72, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  padding: 14px;
}

.control-title p,
.chat-header p {
  margin: 0 0 6px;
  color: #f06413;
  font-size: 13px;
  font-weight: 900;
}

.control-title h1,
.chat-header h2 {
  margin: 0;
  font-size: 24px;
}

.field-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  color: #2b3a50;
  font-size: 13px;
  font-weight: 900;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid rgba(35, 50, 72, 0.18);
  border-radius: 8px;
  color: #152034;
  background: rgba(255, 255, 255, 0.9);
  font-weight: 800;
  outline: none;
}

select,
input {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 112px;
  resize: vertical;
  padding: 12px;
  line-height: 1.65;
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(47, 134, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(47, 134, 255, 0.12);
}

.wallet-card button {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  border: 0;
  background: rgba(218, 248, 232, 0.82);
  color: #087a55;
  padding: 0 14px;
  cursor: pointer;
}

.wallet-menu {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.wallet-menu div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.chat-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
}

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

.message-list {
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
  padding: 16px;
}

.message {
  display: grid;
  gap: 8px;
  max-width: 78%;
}

.message.user {
  justify-self: end;
}

.bubble {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(35, 50, 72, 0.13);
  padding: 12px 14px;
  line-height: 1.65;
  font-weight: 800;
}

.message.user .bubble {
  color: #fff;
  background: linear-gradient(90deg, var(--blue), var(--pink));
}

.thumb-row,
.upload-preview,
.preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.thumb,
.preview-tile {
  overflow: hidden;
  width: 78px;
  height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3f8;
}

.thumb img,
.preview-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.progress-card {
  display: grid;
  gap: 10px;
  margin: 0 16px 12px;
  padding: 12px;
  border: 1px solid rgba(47, 134, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
}

.progress-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #25354a;
  font-size: 13px;
  font-weight: 900;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(47, 134, 255, 0.12);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--pink));
  transition: width 300ms ease;
}

.preview-tile {
  display: grid;
  place-items: center;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(47, 134, 255, 0.76), rgba(237, 81, 185, 0.76)),
    var(--tile-bg, #dfe8f3);
  background-size: cover;
  background-position: center;
  font-size: 12px;
  font-weight: 900;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
}

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

.upload-button {
  position: relative;
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 0 12px;
  color: #fff;
  background: linear-gradient(90deg, var(--orange), var(--pink));
  cursor: pointer;
}

.upload-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-preview .thumb {
  width: 42px;
  height: 42px;
}

.login-dialog {
  width: min(420px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.login-dialog::backdrop {
  background: rgba(18, 24, 39, 0.38);
}

.login-dialog form {
  display: grid;
  gap: 14px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.dialog-head button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 900;
}

.notice-empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-weight: 800;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .workspace-tabs,
  .top-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .workspace-view {
    grid-template-columns: 220px minmax(280px, 340px) minmax(360px, 1fr);
  }

  .portal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .portal-hero h1 {
    font-size: 40px;
  }

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

  .workspace-view {
    height: auto;
  }

  .history-column,
  .control-column,
  .chat-column {
    min-height: 360px;
  }

  .message {
    max-width: 100%;
  }
}
