:root {
  --black: #111111;
  --black-2: #1b1b1b;
  --yellow: #ffc400;
  --yellow-dark: #e9ae00;
  --yellow-soft: #fff8da;
  --ink: #191919;
  --muted: #6f6f6f;
  --line: #e7e3d8;
  --surface: #faf9f5;
  --white: #ffffff;
  --danger: #c9364f;
  --shadow: 0 24px 70px rgba(31, 25, 5, .15);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  color: var(--ink);
  background: var(--white);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.auth-view {
  position: relative;
  display: grid;
  min-height: 100%;
  place-items: center;
  overflow: hidden;
  padding: 96px 24px 40px;
  background:
    radial-gradient(circle at 12% 82%, rgba(255,196,0,.25), transparent 28%),
    radial-gradient(circle at 91% 10%, rgba(255,196,0,.16), transparent 26%),
    linear-gradient(145deg, #fffdf7, #f7f5ec);
}
.auth-view::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: .32;
  background-image: radial-gradient(#d9d1b7 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: linear-gradient(to bottom, black, transparent 74%);
}
.auth-brand {
  position: absolute;
  z-index: 2;
  top: 28px;
  left: 36px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.auth-brand > div { display: flex; flex-direction: column; }
.auth-brand strong { font-size: 20px; letter-spacing: -.03em; }
.auth-brand span { margin-top: 1px; color: var(--muted); font-size: 12px; }
.brand-logo { width: 48px; height: 48px; object-fit: contain; }
.brand-logo.small { width: 39px; height: 39px; }

.auth-card {
  position: relative;
  z-index: 2;
  width: min(448px, 100%);
  padding: 40px;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 25px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}
.auth-card::before {
  position: absolute;
  top: 0;
  left: 38px;
  width: 74px;
  height: 5px;
  content: "";
  border-radius: 0 0 7px 7px;
  background: var(--yellow);
}
.eyebrow { color: #a77b00; font-size: 11px; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.auth-card h1 { margin: 10px 0 8px; font-size: 29px; letter-spacing: -.04em; }
.auth-card > p { margin: 0 0 25px; color: var(--muted); }
.auth-card form { display: grid; gap: 15px; }
.auth-card label { display: grid; gap: 7px; color: #3f3c34; font-size: 13px; font-weight: 750; }
.auth-card input, .inline-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  background: #fcfbf7;
  transition: .2s;
}
.auth-card input:focus, .inline-form input:focus {
  border-color: var(--yellow-dark);
  background: white;
  box-shadow: 0 0 0 3px rgba(255,196,0,.19);
}
.primary {
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  color: var(--black);
  background: var(--yellow);
  box-shadow: 0 7px 17px rgba(207,155,0,.22);
  font-weight: 800;
}
.primary:hover { background: #ffd028; transform: translateY(-1px); }
.primary:disabled { opacity: .5; transform: none; cursor: not-allowed; }
.wide { width: 100%; margin-top: 5px; padding: 13px; }
.text-button { display: block; margin: 19px auto 0; border: 0; color: #876400; background: none; font-weight: 750; }
.auth-note { margin: 18px 0 0 !important; color: #969181 !important; font-size: 12px !important; text-align: center; }
.registration-result { margin-top: 15px; padding: 11px 13px; border: 1px solid #e4c85c; border-radius: 10px; color: #63500c; background: var(--yellow-soft); font-size: 12px; line-height: 1.5; }
.auth-provider {
  position: absolute;
  z-index: 2;
  bottom: 25px;
  left: 34px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 13px 7px 9px;
  border: 1px solid rgba(186,145,0,.18);
  border-radius: 14px;
  background: rgba(255,255,255,.62);
  backdrop-filter: blur(10px);
}
.auth-provider span { color: #8a816b; font-size: 10px; letter-spacing: .08em; writing-mode: vertical-rl; }
.auth-provider img { width: 76px; height: 76px; object-fit: contain; }
.auth-decoration { position: absolute; border: 1px solid rgba(215,164,0,.14); border-radius: 50%; }
.auth-decoration.one { bottom: -110px; left: -90px; width: 370px; height: 370px; box-shadow: 0 0 0 42px rgba(255,196,0,.04); }
.auth-decoration.two { top: -150px; right: -80px; width: 410px; height: 410px; box-shadow: 0 0 0 58px rgba(255,196,0,.035); }

.app-shell { display: grid; grid-template-columns: 282px 1fr; height: 100%; background: #fff; }
.sidebar { display: flex; min-width: 0; flex-direction: column; padding: 17px 14px 14px; color: white; background: var(--black); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 7px 18px; }
.sidebar-brand > div { display: flex; min-width: 0; flex-direction: column; }
.sidebar-brand strong { color: white; font-size: 15px; letter-spacing: -.02em; }
.sidebar-brand span { margin-top: 1px; color: #8e8e8e; font-size: 10px; }
.sidebar-brand .icon-button { margin-left: auto; color: white; }
.new-chat {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 11px 14px;
  gap: 10px;
  border: 1px solid rgba(255,196,0,.42);
  border-radius: 11px;
  color: var(--black);
  background: var(--yellow);
  font-weight: 800;
  text-align: left;
}
.new-chat:hover { background: #ffd12f; }
.new-chat span { font-size: 20px; font-weight: 400; }
.history-label { padding: 22px 12px 8px; color: #777; font-size: 10px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.conversation-list { display: grid; overflow-y: auto; flex: 1; align-content: start; gap: 3px; }
.conversation-item {
  position: relative;
  display: flex;
  overflow: hidden;
  align-items: center;
  padding: 9px 36px 9px 12px;
  border: 0;
  border-radius: 8px;
  color: #aaa;
  background: none;
  font-size: 13px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversation-item:hover { color: white; background: #232323; }
.conversation-item.active { color: var(--black); background: var(--yellow-soft); }
.conversation-delete { position: absolute; right: 7px; padding: 4px; border: 0; color: #777; background: none; opacity: 0; }
.conversation-item:hover .conversation-delete, .conversation-item.active .conversation-delete { opacity: 1; }
.sidebar-footer { padding-top: 10px; border-top: 1px solid #292929; }
.sidebar-action { width: 100%; padding: 10px; border: 0; border-radius: 8px; color: #ccc; background: none; text-align: left; }
.sidebar-action:hover { color: var(--yellow); background: #222; }
.sidebar-company { display: flex; align-items: center; justify-content: space-between; margin: 5px 5px 2px; padding: 8px 9px; border: 1px solid #292929; border-radius: 10px; background: #151515; }
.sidebar-company span { color: #666; font-size: 9px; letter-spacing: .08em; }
.sidebar-company img { width: 52px; height: 52px; object-fit: contain; }
.account-row { display: flex; align-items: center; gap: 10px; margin-top: 5px; padding: 10px 7px; }
.account-row > div:nth-child(2) { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.account-row strong, .account-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-row strong { font-size: 13px; }
.account-row span { color: #7f7f7f; font-size: 11px; }
.avatar { display: grid; width: 33px; height: 33px; place-items: center; border: 1px solid #4d4d4d; border-radius: 10px; color: var(--yellow); background: #292929; font-size: 12px; font-weight: 850; }
.icon-button { padding: 5px; border: 0; border-radius: 7px; color: var(--muted); background: none; font-size: 19px; }
.icon-button:hover { background: rgba(128,128,128,.13); }

.chat-main { display: grid; min-width: 0; height: 100%; grid-template-rows: 65px 1fr auto; background: #fff; }
.topbar { display: flex; height: 65px; align-items: center; justify-content: space-between; padding: 0 27px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.93); }
.topbar > div:first-of-type { display: flex; min-width: 0; flex-direction: column; }
.topbar strong { overflow: hidden; max-width: 50vw; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.topbar span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.status-pill { padding: 6px 10px; border: 1px solid #e7dfc6; border-radius: 30px; color: #5a5548; background: #fffaf0; font-size: 11px; }
.status-pill i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #26a75d; }
.status-pill.offline i { background: var(--yellow-dark); }
.messages { overflow-y: auto; padding: 42px max(24px, calc((100% - 830px)/2)) 30px; scroll-behavior: smooth; }
.welcome { max-width: 830px; margin: 6vh auto 0; text-align: center; }
.welcome-mark { display: grid; width: 78px; height: 78px; margin: auto; place-items: center; border: 1px solid #eee7d0; border-radius: 24px; background: linear-gradient(145deg, #fffef9, #fff4c8); box-shadow: 0 14px 34px rgba(167,126,0,.14); }
.welcome-mark img { width: 64px; height: 64px; object-fit: contain; }
.welcome h2 { margin: 20px 0 6px; font-size: 29px; letter-spacing: -.04em; }
.welcome > p { margin: 0; color: var(--muted); }
.suggestions { display: grid; margin-top: 33px; grid-template-columns: 1fr 1fr; gap: 11px; }
.suggestions button { position: relative; padding: 16px 17px 16px 20px; border: 1px solid var(--line); border-radius: 14px; color: var(--muted); background: #fff; box-shadow: 0 4px 15px rgba(34,27,3,.04); text-align: left; }
.suggestions button::before { position: absolute; top: 17px; bottom: 17px; left: 0; width: 4px; content: ""; border-radius: 0 4px 4px 0; background: var(--yellow); }
.suggestions button:hover { border-color: #e2c55e; background: #fffdf6; transform: translateY(-1px); }
.suggestions span { display: block; margin-bottom: 5px; color: var(--ink); font-weight: 800; }
.message { display: grid; max-width: 830px; margin: 0 auto 27px; grid-template-columns: 38px 1fr; gap: 13px; }
.message.user { grid-template-columns: 1fr; }
.message.user .message-body { max-width: 78%; justify-self: end; padding: 11px 15px; border: 1px solid #f0d679; border-radius: 17px 17px 4px 17px; background: var(--yellow-soft); }
.message-avatar { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid #eee3bf; border-radius: 12px; background: #fff9e1; }
.message-avatar img { width: 31px; height: 31px; object-fit: contain; }
.message-body { min-width: 0; font-size: 15px; line-height: 1.72; }
.message-body p { margin: 0 0 11px; }
.message-body h1, .message-body h2, .message-body h3 { margin: 17px 0 8px; line-height: 1.35; }
.message-body ul { margin: 5px 0 12px; padding-left: 22px; }
.message-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.file-tag { padding: 5px 8px; border: 1px solid #e4d69c; border-radius: 8px; color: #655b3d; background: white; font-size: 11px; }
.export-actions { display: flex; gap: 7px; margin-top: 14px; }
.export-actions button { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; color: #5e5b52; background: white; font-size: 11px; }
.export-actions button:hover { border-color: #e0bd39; color: #765800; background: #fffdf4; }
.generated-image { display: block; max-width: min(620px,100%); border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 8px 28px rgba(19,19,19,.1); }

.composer-wrap { padding: 10px max(20px, calc((100% - 830px)/2)) 15px; background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 12%); }
.composer { padding: 12px 12px 9px; border: 1px solid #cfcabf; border-radius: 18px; background: #fff; box-shadow: 0 9px 29px rgba(31,26,8,.1); }
.composer:focus-within { border-color: #d8ad17; box-shadow: 0 8px 30px rgba(215,166,0,.14); }
.composer textarea { width: 100%; min-height: 29px; max-height: 150px; padding: 2px 5px; resize: none; border: 0; outline: 0; color: var(--ink); line-height: 1.55; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.composer-actions > div { display: flex; align-items: center; gap: 7px; }
.attach-button { display: flex; height: 31px; align-items: center; padding: 0 9px; gap: 5px; border: 1px solid var(--line); border-radius: 9px; color: #5b5b5b; cursor: pointer; }
.attach-button span { font-size: 19px; line-height: 1; }
.attach-button b { font-size: 12px; font-weight: 700; }
.mode-button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; color: #696969; background: white; font-size: 12px; }
.mode-button.active { border-color: #e2bb2d; color: #684f00; background: var(--yellow-soft); }
.send-button { width: 35px; height: 35px; border: 0; border-radius: 10px; color: var(--black); background: var(--yellow); font-size: 20px; font-weight: 800; }
.send-button:hover { background: #ffd12c; }
.send-button:disabled { opacity: .45; cursor: wait; }
.disclaimer { margin: 8px 0 0; color: #99958a; font-size: 10px; text-align: center; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 7px; }
.attachment-chip { display: flex; align-items: center; padding: 7px 9px; gap: 7px; border: 1px solid #e1d8b9; border-radius: 10px; background: #fffdf5; font-size: 11px; }
.attachment-chip button { padding: 0; border: 0; color: #8d8879; background: none; }
.upload-status { margin-bottom: 7px; padding: 9px 11px; border: 1px solid #e1d18f; border-radius: 10px; color: #66500a; background: #fffbed; font-size: 12px; }
.upload-status.success { border-color: #bad8bd; color: #245c2b; background: #f2fbf3; }
.upload-status.error { border-color: #e3b4bb; color: #9b2035; background: #fff4f6; }
.typing { display: flex; gap: 5px; padding-top: 9px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #b9961f; animation: bounce 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

.modal { width: min(900px, calc(100% - 30px)); max-height: calc(100vh - 40px); padding: 25px; overflow:auto; border: 0; border-radius: 20px; color: var(--ink); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(15,15,15,.62); backdrop-filter: blur(4px); }
.modal-head, .section-head { display: flex; align-items: flex-start; justify-content: space-between; }
.modal h2 { margin: 5px 0 0; }
.usage-card { margin: 20px 0; padding: 15px; border: 1px solid #e7dba8; border-radius: 14px; background: #fffaf0; }
.usage-card > div:first-child { display: flex; justify-content: space-between; font-size: 12px; }
.progress { overflow: hidden; height: 7px; margin: 10px 0 7px; border-radius: 10px; background: #ece7d9; }
.progress i { display: block; width: 0; height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--yellow-dark), var(--yellow)); }
.usage-card small, .section-head p { color: var(--muted); font-size: 11px; }
.section-head h3 { margin: 0; }
.section-head p { margin: 4px 0; }
.inline-form { display: grid; margin: 13px 0; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.user-list { margin-top: 12px; border-top: 1px solid var(--line); }
.user-row { display: grid; align-items: center; padding: 13px 3px; border-bottom: 1px solid var(--line); grid-template-columns: 1fr auto auto; gap: 10px; }
.user-row > div { display: flex; flex-direction: column; }
.user-row small { color: var(--muted); }
.role-badge { padding: 4px 7px; border-radius: 20px; color: #694f00; background: var(--yellow-soft); font-size: 10px; }
.user-row button { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: white; font-size: 11px; }
.user-row button.danger { color: var(--danger); }
.log-section-head { margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--line); }
.secondary-button { padding: 8px 11px; border: 1px solid #ddbd42; border-radius: 9px; color: #6b5200; background: #fffdf4; font-size: 11px; font-weight: 750; }
.secondary-button:hover { background: var(--yellow-soft); }
.table-wrap { width: 100%; overflow: auto; }
.company-log-wrap { max-height: 280px; margin-top: 10px; border: 1px solid var(--line); border-radius: 11px; }
.log-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.log-table th { position: sticky; top: 0; padding: 9px 10px; color: #817b6c; background: #f8f6ef; text-align: left; white-space: nowrap; }
.log-table td { padding: 9px 10px; border-top: 1px solid #efede5; vertical-align: top; }
.log-table .empty { padding: 24px; color: var(--muted); text-align: center; }
.toast { position: fixed; z-index: 20; bottom: 26px; left: 50%; padding: 10px 15px; transform: translate(-50%,20px); border-radius: 10px; color: white; background: var(--black); box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 12px; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: translate(-50%,0); opacity: 1; }
.launch-notice {
  position: fixed;
  z-index: 30;
  top: 18px;
  left: 50%;
  display: flex;
  width: min(660px, calc(100% - 30px));
  align-items: center;
  padding: 12px 15px;
  transform: translateX(-50%);
  gap: 12px;
  border: 1px solid #d4a800;
  border-radius: 12px;
  color: #191500;
  background: #fff3b8;
  box-shadow: 0 10px 30px rgba(67,51,0,.18);
  font-size: 12px;
}
.launch-notice strong { flex: none; }
.launch-notice span { color: #695a22; }
.mobile-only { display: none; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; width: 282px; transform: translateX(-100%); box-shadow: var(--shadow); transition: .25s; }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: block; }
  .topbar { padding: 0 15px; }
  .topbar .mobile-only { margin-right: 8px; }
  .topbar > div:first-of-type { margin-right: auto; }
  .messages { padding: 28px 16px; }
  .composer-wrap { padding: 9px 12px; }
  .suggestions { grid-template-columns: 1fr; }
  .welcome { margin-top: 2vh; }
  .welcome h2 { font-size: 23px; }
  .auth-brand { top: 20px; left: 22px; }
  .auth-card { padding: 31px 24px; }
  .auth-provider { position: relative; bottom: auto; left: auto; margin-top: 16px; padding: 5px 11px 5px 7px; }
  .auth-provider img { width: 58px; height: 58px; }
  .message.user .message-body { max-width: 90%; }
  .inline-form { grid-template-columns: 1fr; }
  .status-pill { display: none; }
  .launch-notice { top: 10px; align-items: flex-start; flex-direction: column; gap: 3px; }
}
