:root {
  color-scheme: dark;
  --bg: #040914;
  --surface: rgba(11, 25, 49, .9);
  --surface-strong: #101f3e;
  --line: rgba(114, 177, 255, .25);
  --line-strong: rgba(62, 190, 255, .55);
  --text: #f2f7ff;
  --muted: #a9bdd9;
  --blue: #14b8ff;
  --blue-deep: #026de8;
  --purple: #8559ff;
  --danger: #ff718b;
  --success: #61e3a3;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, rgba(0, 135, 255, .2), transparent 31rem),
    radial-gradient(circle at 100% 100%, rgba(124, 72, 255, .22), transparent 32rem),
    var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.portal-shell { width: min(100%, 1100px); margin: 0 auto; padding: clamp(20px, 5vw, 64px) 20px; }
.portal-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(15, 32, 62, .95), rgba(4, 12, 29, .96));
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}
.portal-header {
  display: grid;
  grid-template-columns: minmax(120px, 190px) 1fr;
  gap: clamp(20px, 4vw, 42px);
  align-items: center;
  padding: clamp(24px, 5vw, 52px);
  background: linear-gradient(110deg, rgba(1, 42, 99, .72), rgba(35, 15, 83, .62));
  border-bottom: 1px solid var(--line);
}
.brand { display: block; }
.brand img { display: block; width: 100%; max-width: 180px; max-height: 160px; object-fit: contain; filter: drop-shadow(0 12px 20px rgba(0, 0, 0, .36)); }
.eyebrow { display: block; color: #7fcbff; font-size: .72rem; font-weight: 800; letter-spacing: .14em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(2rem, 5vw, 3.45rem); line-height: 1; letter-spacing: -.045em; }
h2 { margin-bottom: 7px; font-size: 1.12rem; }
p { color: var(--muted); line-height: 1.55; }
.header-copy p { max-width: 620px; margin-bottom: 0; }
.status-message { margin: 20px clamp(20px, 4vw, 46px) 0; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: rgba(3, 12, 29, .48); }
.status-message.loading::before { content: ""; display: inline-block; width: .75rem; height: .75rem; margin-right: .6rem; border: 2px solid rgba(140, 220, 255, .28); border-top-color: var(--blue); border-radius: 50%; vertical-align: -.07rem; animation: spin .8s linear infinite; }
.status-message.error { color: #ffc1cb; border-color: rgba(255, 105, 135, .45); }
.portal-app { padding: clamp(20px, 4vw, 46px); }
.mode-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; padding: 6px; border: 1px solid var(--line); border-radius: 17px; background: rgba(0, 3, 12, .32); }
.mode-tab { min-height: 46px; padding: 9px 12px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; font-weight: 700; transition: .18s ease; }
.mode-tab:hover { color: var(--text); background: rgba(114, 177, 255, .1); }
.mode-tab.is-active { color: #fff; background: linear-gradient(115deg, var(--blue-deep), var(--purple)); box-shadow: 0 9px 24px rgba(47, 91, 255, .24); }
.search-panel { margin-top: 24px; padding: clamp(19px, 3vw, 30px); border: 1px solid var(--line); border-radius: 20px; background: rgba(7, 18, 40, .68); }
.panel-heading { display: flex; gap: 14px; align-items: flex-start; }
.panel-heading > span { display: grid; width: 38px; height: 38px; place-items: center; flex: 0 0 auto; border-radius: 12px; background: rgba(20, 184, 255, .12); font-size: 1.25rem; }
.panel-heading p { margin-bottom: 0; font-size: .93rem; }
.search-form { margin-top: 22px; }
.type-picker { display: flex; gap: 10px; margin-bottom: 12px; }
.type-picker label { position: relative; display: inline-flex; }
.type-picker input { position: absolute; opacity: 0; pointer-events: none; }
.type-picker span { padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .87rem; font-weight: 700; transition: .18s; }
.type-picker input:checked + span { border-color: var(--blue); color: #fff; background: rgba(20, 184, 255, .16); }
.search-row { display: flex; gap: 10px; }
input, select, textarea { width: 100%; border: 1px solid rgba(144, 189, 247, .28); border-radius: 12px; outline: none; color: var(--text); background: rgba(0, 8, 22, .7); transition: border-color .18s, box-shadow .18s; }
input, select { min-height: 49px; padding: 0 14px; }
textarea { padding: 12px 14px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20, 184, 255, .14); }
.primary-button, .outline-button { min-height: 49px; padding: 0 18px; border-radius: 12px; font-weight: 800; white-space: nowrap; transition: transform .18s, filter .18s, background .18s; }
.primary-button { border: 0; color: #fff; background: linear-gradient(112deg, var(--blue-deep), var(--purple)); box-shadow: 0 12px 25px rgba(30, 94, 255, .24); }
.primary-button:hover { filter: brightness(1.12); transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .63; transform: none; }
.outline-button { border: 1px solid var(--line-strong); color: #d8edff; background: rgba(20, 118, 255, .08); }
.outline-button:hover { background: rgba(20, 118, 255, .18); }
.results-section { margin-top: 26px; }
.section-title-row { display: flex; gap: 14px; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-title-row h2 { margin: 0; }
#results-count { color: var(--muted); font-size: .86rem; }
.results-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(226px, 1fr)); gap: 14px; }
.result-card { display: grid; grid-template-columns: 64px 1fr; gap: 12px; min-height: 108px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: rgba(8, 22, 49, .72); }
.result-poster { width: 64px; height: 84px; overflow: hidden; border-radius: 10px; background: linear-gradient(145deg, #12345e, #25145d); }
.result-poster img { width: 100%; height: 100%; object-fit: cover; }
.result-content { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.result-content h3 { margin: 2px 0 5px; overflow: hidden; font-size: .98rem; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.result-meta { margin-bottom: 10px; color: var(--muted); font-size: .8rem; }
.result-card .primary-button { min-height: 35px; margin-top: auto; padding: 0 11px; font-size: .82rem; }
.empty-results { grid-column: 1 / -1; padding: 26px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; }
.manual-panel { display: flex; gap: 22px; align-items: center; justify-content: space-between; margin-top: 30px; padding: 23px; border: 1px solid rgba(130, 100, 255, .36); border-radius: 18px; background: linear-gradient(110deg, rgba(35, 47, 118, .42), rgba(56, 24, 104, .34)); }
.manual-panel h2 { margin: 3px 0 4px; }
.manual-panel p { margin-bottom: 0; font-size: .9rem; }
.manual-form-section { margin-top: 18px; }
.manual-form { padding: clamp(19px, 3vw, 29px); border: 1px solid var(--line); border-radius: 18px; background: rgba(4, 14, 32, .78); }
.form-title-row { display: flex; gap: 18px; justify-content: space-between; }
.form-title-row h2 { margin-bottom: 5px; }
.form-title-row p { margin-bottom: 19px; font-size: .9rem; }
.icon-button { width: 36px; height: 36px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: transparent; font-size: 1.5rem; line-height: 1; }
.icon-button:hover { color: #fff; border-color: var(--line-strong); }
.form-grid { display: grid; grid-template-columns: 1fr 150px; gap: 14px; }
.form-grid label { display: grid; gap: 7px; color: #dce9fa; font-size: .86rem; font-weight: 700; }
.full-field { grid-column: 1 / -1; }
.optional { color: var(--muted); font-weight: 500; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.toast { position: fixed; z-index: 10; right: 20px; bottom: 20px; width: min(420px, calc(100% - 40px)); padding: 15px 17px; border: 1px solid var(--line-strong); border-radius: 14px; color: #eaf6ff; background: #0b2448; box-shadow: 0 18px 45px rgba(0, 0, 0, .42); }
.toast.success { border-color: rgba(97, 227, 163, .62); background: #103a35; }
.toast.error { border-color: rgba(255, 113, 139, .62); background: #461b2a; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 620px) {
  .portal-shell { padding: 12px; }
  .portal-card { border-radius: 19px; }
  .portal-header { grid-template-columns: 1fr; gap: 18px; }
  .brand img { width: 136px; max-height: 112px; }
  .mode-tabs { grid-template-columns: 1fr; }
  .search-row, .manual-panel { align-items: stretch; flex-direction: column; }
  .primary-button, .outline-button { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label, .full-field { grid-column: auto; }
}
