:root {
  --bg: #101418;
  --bg-grid: rgba(125, 219, 255, 0.08);
  --panel: rgba(20, 27, 32, 0.92);
  --panel-soft: rgba(26, 35, 41, 0.86);
  --text: #edf6f8;
  --muted: #8fa3ad;
  --line: rgba(132, 184, 202, 0.24);
  --line-strong: rgba(118, 224, 220, 0.48);
  --accent: #35d3c5;
  --accent-dark: #22a99d;
  --accent-warm: #f0b35b;
  --warn: #f0b35b;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px),
    linear-gradient(180deg, var(--bg-grid) 1px, transparent 1px),
    radial-gradient(circle at 20% 0%, rgba(53, 211, 197, 0.16), transparent 34%),
    var(--bg);
  background-size: 34px 34px, 34px 34px, auto, auto;
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(115deg, transparent 0%, transparent 38%, rgba(53, 211, 197, 0.14) 48%, transparent 58%, transparent 100%),
    linear-gradient(70deg, transparent 0%, transparent 58%, rgba(125, 219, 255, 0.08) 64%, transparent 72%, transparent 100%);
  background-size: 220% 220%, 180% 180%;
  animation: ambient-sweep 12s linear infinite;
  pointer-events: none;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #071315;
  cursor: pointer;
  font-weight: 600;
  padding: 9px 14px;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: 0 0 18px rgba(53, 211, 197, 0.22);
  transform: translateY(-1px);
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.ghost-button:hover:not(:disabled) {
  background: rgba(53, 211, 197, 0.09);
  border-color: var(--line-strong);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 13, 16, 0.7);
  color: var(--text);
  padding: 9px 10px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(53, 211, 197, 0.11);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #6f838c;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  animation: rise-in 260ms ease both;
}

.app-header p {
  margin-bottom: 0;
}

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

.login-panel,
.admin-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  padding: 22px;
}

.login-panel {
  width: min(420px, 100%);
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
}

.admin-layout.single {
  grid-template-columns: 1fr;
}

.user-row,
.audit-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 10px;
  padding: 10px;
}

.permission-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.permission-row label,
.admin-panel label {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.permission-row input,
.admin-panel label input {
  width: auto;
}

.small-meta {
  color: var(--muted);
  font-size: 13px;
}

.danger-button {
  background: #c94d57;
  color: white;
}

.danger-button:hover:not(:disabled) {
  background: #a83e47;
  box-shadow: 0 0 18px rgba(201, 77, 87, 0.22);
}

.modal {
  align-items: center;
  background: rgba(3, 8, 10, 0.72);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 20;
}

.modal-panel {
  animation: rise-in 180ms ease both;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 440px;
  padding: 18px;
  width: 100%;
}

.modal-form {
  display: grid;
  gap: 12px;
}

.option-form {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 10px;
  margin-bottom: 14px;
}

.option-groups {
  display: grid;
  gap: 12px;
}

.danger-zone {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.danger-zone p {
  margin-bottom: 0;
}

.assistant-widget {
  position: fixed;
  z-index: 15;
}

.with-assistant .assistant-widget {
  position: sticky;
  top: 18px;
  z-index: 1;
}

.assistant-widget.bottom-right {
  bottom: 22px;
  right: 22px;
}

.assistant-widget.bottom-left {
  bottom: 22px;
  left: 22px;
}

.assistant-widget.top-right {
  right: 22px;
  top: 22px;
}

.assistant-widget.top-left {
  left: 22px;
  top: 22px;
}

.assistant-toggle {
  border-radius: 999px;
  height: 58px;
  width: 58px;
}

.assistant-panel {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
  width: min(360px, calc(100vw - 44px));
}

.side-assistant {
  grid-template-rows: auto auto auto;
  margin-bottom: 0;
  padding: 14px;
  width: 100%;
}

.top-left .assistant-panel,
.top-right .assistant-panel {
  margin-bottom: 0;
  margin-top: 10px;
}

.assistant-actions {
  display: flex;
  gap: 8px;
}

.assistant-messages {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.side-assistant .assistant-messages {
  max-height: min(42vh, 360px);
  min-height: 180px;
}

.assistant-message {
  background: rgba(53, 211, 197, 0.08);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  white-space: pre-wrap;
}

.assistant-message.user {
  background: rgba(53, 211, 197, 0.16);
}

.assistant-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.assistant-result {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  color: var(--text);
  text-align: left;
}

.ai-loading {
  align-items: center;
  background: rgba(2, 8, 10, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 30;
}

.ai-loader-panel {
  align-items: center;
  animation: rise-in 180ms ease both;
  background: rgba(14, 23, 28, 0.94);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow), 0 0 38px rgba(53, 211, 197, 0.16);
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 28px;
  width: min(340px, calc(100vw - 36px));
}

.ai-loader-panel strong {
  font-size: 20px;
}

.ai-loader-panel span {
  color: var(--muted);
  font-size: 14px;
}

.liquid-orb {
  border: 1px solid rgba(53, 211, 197, 0.55);
  border-radius: 999px;
  box-shadow: inset 0 0 18px rgba(53, 211, 197, 0.1), 0 0 28px rgba(53, 211, 197, 0.24);
  height: 118px;
  overflow: hidden;
  position: relative;
  width: 118px;
}

.liquid-fill {
  animation: liquid-rise 3.8s ease-in-out infinite, liquid-sway 2.2s ease-in-out infinite;
  background: linear-gradient(180deg, rgba(87, 238, 226, 0.92), rgba(21, 139, 162, 0.78));
  border-radius: 46% 54% 44% 56%;
  bottom: -20%;
  height: 76%;
  left: -12%;
  position: absolute;
  width: 124%;
}

.liquid-fill::before,
.liquid-fill::after {
  background: rgba(237, 246, 248, 0.18);
  border-radius: 45%;
  content: "";
  height: 42px;
  left: 0;
  position: absolute;
  top: -18px;
  width: 100%;
}

.liquid-fill::before {
  animation: wave 2.4s linear infinite;
}

.liquid-fill::after {
  animation: wave 3.1s linear infinite reverse;
  opacity: 0.55;
}

.liquid-gloss {
  border-radius: 999px;
  inset: 14px 22px auto auto;
  height: 34px;
  position: absolute;
  width: 18px;
  background: rgba(237, 246, 248, 0.3);
  filter: blur(1px);
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  animation: rise-in 300ms ease both;
}

.entry-card {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 22px;
  text-align: left;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.entry-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 1px solid rgba(53, 211, 197, 0.42);
  pointer-events: none;
}

.entry-card::after {
  content: "";
  position: absolute;
  inset: -40% -80%;
  background: linear-gradient(115deg, transparent 42%, rgba(237, 246, 248, 0.14) 50%, transparent 58%);
  opacity: 0;
  transform: translateX(-26%);
  transition: opacity 180ms ease;
  pointer-events: none;
}

.entry-card:hover {
  border-color: var(--accent);
  background: rgba(26, 40, 45, 0.96);
}

.entry-card:hover::after {
  opacity: 1;
  animation: card-sweep 900ms ease;
}

.entry-card strong {
  display: block;
  margin-bottom: 12px;
  font-size: 22px;
}

.entry-card span {
  color: var(--muted);
  line-height: 1.5;
}

.app-view {
  margin-top: 12px;
  animation: rise-in 220ms ease both;
}

.view-header {
  margin-bottom: 12px;
}

.view-header h2,
.capture h2 {
  margin: 12px 0 8px;
}

.back-button {
  width: auto;
  padding: 7px 11px;
}

.capture,
.search-panel,
.results,
.detail,
.side-assistant {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.capture::after,
.search-panel::after,
.results::after,
.detail::after,
.side-assistant::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(53, 211, 197, 0.18), transparent);
  height: 1px;
  opacity: 0.7;
  animation: edge-flow 5s linear infinite;
  pointer-events: none;
}

.capture {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  padding: 18px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 28px;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

p {
  color: var(--muted);
}

.form-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.quick-actions,
.title-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.quick-actions {
  justify-content: flex-end;
  margin-top: 10px;
}

.form-row > * {
  min-width: 0;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
  width: 100%;
}

.field-label {
  color: #b7cbd1;
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 2px 0 4px;
}

.hidden {
  display: none !important;
}

.workspace {
  display: grid;
  grid-template-columns: 230px minmax(320px, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.workspace.with-assistant {
  grid-template-columns: 260px minmax(360px, 1fr) 380px;
}

.search-panel,
.results,
.detail,
.side-assistant {
  padding: 14px;
}

.search-panel {
  display: grid;
  gap: 10px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.problem-list {
  display: grid;
  gap: 10px;
}

.problem-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  cursor: pointer;
  padding: 12px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.problem-card.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.problem-card:hover {
  background: rgba(32, 45, 52, 0.92);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.problem-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.badge {
  border-radius: 999px;
  background: rgba(53, 211, 197, 0.1);
  border: 1px solid rgba(53, 211, 197, 0.22);
  color: #b7f4ed;
  font-size: 12px;
  padding: 3px 8px;
}

.badge.warn {
  background: rgba(240, 179, 91, 0.12);
  border-color: rgba(240, 179, 91, 0.28);
  color: var(--warn);
}

.snippet {
  color: var(--muted);
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.detail-form,
.draft-form {
  display: grid;
  gap: 10px;
}

.detail-form {
  display: none;
}

.draft-form {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.draft-form h3 {
  margin: 0;
}

.detail-form.editing {
  display: grid;
}

.detail-view {
  display: grid;
  gap: 12px;
}

.detail-view h3 {
  margin: 0;
  font-size: 18px;
}

.detail-view h4 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.detail-view p,
.detail-view pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-view pre {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 13, 16, 0.68);
  padding: 10px;
}

.empty-detail {
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.detail-modal-panel {
  max-height: min(86vh, 860px);
  max-width: min(980px, calc(100vw - 36px));
  overflow: auto;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ambient-sweep {
  from {
    background-position: 0% 50%, 100% 30%;
  }
  to {
    background-position: 220% 50%, -80% 30%;
  }
}

@keyframes card-sweep {
  from {
    transform: translateX(-36%);
  }
  to {
    transform: translateX(36%);
  }
}

@keyframes edge-flow {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

@keyframes liquid-rise {
  0%,
  100% {
    transform: translateY(8%);
  }
  50% {
    transform: translateY(-8%);
  }
}

@keyframes liquid-sway {
  0%,
  100% {
    border-radius: 46% 54% 44% 56%;
  }
  50% {
    border-radius: 55% 45% 58% 42%;
  }
}

@keyframes wave {
  from {
    transform: translateX(-18%) rotate(0deg);
  }
  to {
    transform: translateX(18%) rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

#attachments {
  margin-top: 12px;
}

.attachment-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px;
}

.attachment-list strong {
  color: var(--text);
  font-size: 13px;
}

.attachment-list span {
  word-break: break-all;
}

@media (max-width: 1100px) {
  .entry-grid,
  .admin-layout,
  .capture,
  .workspace {
    grid-template-columns: 1fr;
  }

  .with-assistant .assistant-widget {
    position: static;
  }

  .side-assistant {
    grid-template-rows: auto auto auto;
    min-height: 0;
  }

  .form-row {
    flex-wrap: wrap;
  }

  .quick-actions,
  .title-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}
