:root {
  --ph-bg: #070a0f;
  --ph-panel: rgba(14, 20, 27, .76);
  --ph-panel-strong: rgba(18, 25, 34, .92);
  --ph-line: rgba(144, 225, 230, .16);
  --ph-line-hot: rgba(113, 231, 220, .42);
  --ph-text: #f4f8fa;
  --ph-muted: #9eacb8;
  --ph-cyan: #71e7dc;
  --ph-blue: #73a7ff;
  --ph-coral: #ff806d;
  --ph-lime: #b8f36b;
  --ph-danger: #ff6f7e;
  --ph-shadow: 0 22px 70px rgba(0, 0, 0, .42);
  --ph-ease: cubic-bezier(.2, .8, .2, 1);
  --radius: 8px !important;
  --radius-sm: 6px !important;
  --accent: var(--ph-cyan) !important;
  --danger: var(--ph-danger) !important;
  --muted: var(--ph-muted) !important;
  --border: var(--ph-line) !important;
  --border-light: rgba(184, 243, 107, .22) !important;
  color-scheme: dark;
}

* { scrollbar-width: thin; scrollbar-color: rgba(113, 231, 220, .36) transparent; }
*::selection { background: rgba(113, 231, 220, .24); color: #fff; }
html { background: var(--ph-bg); }
body {
  min-height: 100vh;
  background-color: var(--ph-bg) !important;
  background-image: linear-gradient(rgba(7, 10, 15, .72), rgba(7, 10, 15, .86)), url('/static/memory-grid.png') !important;
  background-size: cover !important;
  background-position: var(--bg-x, 50%) var(--bg-y, 50%) !important;
  background-attachment: fixed !important;
  color: var(--ph-text) !important;
  letter-spacing: 0 !important;
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(113,231,220,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(113,231,220,.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.65), transparent 78%);
  z-index: -1;
}

.container, .wrap { width: min(1180px, calc(100% - 32px)) !important; max-width: 1180px !important; margin: 0 auto !important; padding: 24px 0 48px !important; }
.app-bar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 10px 2px;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center;
  border: 1px solid rgba(113,231,220,.45); border-radius: 8px;
  background: linear-gradient(145deg, rgba(113,231,220,.18), rgba(115,167,255,.08));
  box-shadow: inset 0 0 18px rgba(113,231,220,.08), 0 8px 28px rgba(0,0,0,.28);
  color: var(--ph-cyan); font: 700 18px/1 ui-monospace, monospace;
}
.brand-copy { min-width: 0; }
.brand-name { font-size: 18px; font-weight: 750; line-height: 1.1; color: #fff; }
.brand-sub { margin-top: 4px; color: var(--ph-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0 !important; }
.app-status { display: flex; align-items: center; gap: 8px; color: #c7d0d7; font-size: 12px; white-space: nowrap; }
.status-line { width: 20px; height: 2px; background: var(--ph-lime); box-shadow: 0 0 12px rgba(184,243,107,.65); }

.card, main, .modal, #qrSection > div {
  border: 1px solid var(--ph-line) !important;
  border-radius: 8px !important;
  background: var(--ph-panel) !important;
  backdrop-filter: blur(22px) saturate(125%);
  -webkit-backdrop-filter: blur(22px) saturate(125%);
  box-shadow: var(--ph-shadow) !important;
}
.card { padding: clamp(18px, 3vw, 30px) !important; }
.composer-panel { position: relative; overflow: hidden; }
.composer-panel::before, .memory-panel::before {
  content: ''; position: absolute; inset: 0 auto auto 0; width: 100%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--ph-cyan), var(--ph-blue), transparent);
  opacity: .7; pointer-events: none;
}
.composer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.composer-title h1 { margin: 0 0 7px !important; font-size: clamp(22px, 3vw, 30px) !important; font-weight: 730 !important; }
.composer-title .meta { max-width: 700px; margin: 0; line-height: 1.8; }
.utility-rail { display: flex !important; flex-wrap: wrap; justify-content: flex-end; gap: 7px !important; float: none !important; }

h1, h2, h3, h4 { color: var(--ph-text) !important; letter-spacing: 0 !important; }
.meta, .smallmeta { color: var(--ph-muted) !important; }
label { color: #bdc8cf !important; font-size: 12px !important; font-weight: 650; }
textarea, input, select {
  border: 1px solid rgba(151, 176, 190, .2) !important;
  border-radius: 6px !important;
  background: rgba(4, 8, 13, .62) !important;
  color: var(--ph-text) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025) !important;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease !important;
}
textarea { min-height: 230px !important; line-height: 1.65 !important; }
textarea:hover, input:hover, select:hover { border-color: rgba(113,231,220,.34) !important; }
textarea:focus, input:focus, select:focus {
  border-color: var(--ph-cyan) !important;
  background: rgba(5, 11, 16, .84) !important;
  box-shadow: 0 0 0 3px rgba(113,231,220,.1), 0 12px 34px rgba(0,0,0,.16) !important;
  outline: none !important;
}

button, .file-btn {
  min-height: 38px;
  border: 1px solid rgba(113,231,220,.32) !important;
  border-radius: 6px !important;
  background: linear-gradient(135deg, rgba(113,231,220,.94), rgba(86,192,198,.92)) !important;
  color: #061013 !important;
  font-weight: 720 !important;
  letter-spacing: 0 !important;
  box-shadow: 0 7px 22px rgba(48,161,163,.18) !important;
  transition: transform .2s var(--ph-ease), border-color .2s ease, background .2s ease, box-shadow .2s ease !important;
}
button:hover, .file-btn:hover { transform: translateY(-2px); box-shadow: 0 11px 28px rgba(48,161,163,.28) !important; }
button:active, .file-btn:active { transform: translateY(0) scale(.98); }
button.secondary, .btn-ghost {
  background: rgba(255,255,255,.035) !important; color: #d9e3e8 !important;
  border-color: rgba(151,176,190,.18) !important; box-shadow: none !important;
}
button.secondary:hover, .btn-ghost:hover { background: rgba(113,231,220,.1) !important; border-color: rgba(113,231,220,.38) !important; color: #fff !important; }
button.danger, #deleteBtn { background: rgba(255,111,126,.11) !important; color: #ffadb6 !important; border-color: rgba(255,111,126,.28) !important; box-shadow: none !important; }
button:focus-visible, .file-btn:focus-visible, a:focus-visible { outline: 2px solid var(--ph-lime) !important; outline-offset: 3px; }

.form-row { gap: 18px !important; }
.form-side { border-left: 1px solid rgba(151,176,190,.12); padding-left: 18px; }
html[dir=rtl] .form-side { border-left: 0; border-right: 1px solid rgba(151,176,190,.12); padding-left: 0; padding-right: 18px; }
.actions { border-top: 1px solid rgba(151,176,190,.1); margin-top: 18px !important; padding-top: 16px; }
#chars { color: var(--ph-muted); font-variant-numeric: tabular-nums; }
.result { border-radius: 6px !important; }

.memory-panel { position: relative; margin-top: 18px !important; overflow: hidden; }
.feed-header { padding-bottom: 14px; border-bottom: 1px solid rgba(151,176,190,.1); }
.feed-header h2 { font-size: 17px !important; }
#feedCount { color: var(--ph-cyan); font-variant-numeric: tabular-nums; }
.cat-pills { gap: 6px !important; }
.cat-pill { background: rgba(255,255,255,.035) !important; border: 1px solid rgba(151,176,190,.14) !important; color: #aebbc4 !important; }
.cat-pill:hover, .cat-pill.active { background: rgba(113,231,220,.11) !important; border-color: rgba(113,231,220,.42) !important; color: #fff !important; }
.feed-list { gap: 7px !important; }
.feed-item {
  min-height: 64px; padding: 12px 14px !important; border: 1px solid rgba(151,176,190,.1) !important;
  border-radius: 6px !important; background: rgba(5,9,14,.34) !important;
  transition: transform .22s var(--ph-ease), background .2s ease, border-color .2s ease !important;
}
.feed-item:hover { transform: translateX(-3px); background: rgba(16,26,32,.72) !important; border-color: rgba(113,231,220,.34) !important; }
html[dir=ltr] .feed-item:hover { transform: translateX(3px); }
.feed-item .cat-badge { border: 1px solid rgba(255,255,255,.09); }
.feed-item .item-title { color: #edf6f7 !important; }
.feed-item .item-preview { color: #8797a4 !important; }
.feed-loading span { color: var(--ph-cyan); }

.toggle-section { margin-top: 12px !important; }
.toggle-card { box-shadow: 0 12px 40px rgba(0,0,0,.3) !important; }
.modal-overlay { background: rgba(2,5,8,.76) !important; backdrop-filter: blur(10px); }
.modal { background: var(--ph-panel-strong) !important; border-color: rgba(113,231,220,.25) !important; }
.modal-overlay.show .modal { animation: modalIn .32s var(--ph-ease) both; }
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }

.header { align-items: flex-start !important; gap: 18px !important; }
.controls { gap: 7px !important; }
.stats-bar { border: 1px solid rgba(151,176,190,.12) !important; border-radius: 6px !important; background: rgba(5,9,14,.36) !important; }
.codeBox { border: 1px solid rgba(113,231,220,.16) !important; border-radius: 6px !important; background: rgba(2,6,10,.78) !important; box-shadow: inset 0 1px 0 rgba(255,255,255,.03); }
.codeBox pre { color: #dcebec !important; }
.cat-badge { border-radius: 4px !important; }

body > main { width: min(420px, calc(100% - 32px)) !important; padding: 30px !important; position: relative; overflow: hidden; }
body > main::before { content: ''; position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, var(--ph-cyan), var(--ph-blue), var(--ph-coral)); }
body > main h1 { font-size: 28px !important; }
body > main input { height: 48px !important; }
body > main button { height: 46px !important; }

.page-reveal { opacity: 0; transform: translateY(14px); }
.theme-ready .page-reveal { animation: reveal .65s var(--ph-ease) forwards; animation-delay: var(--delay, 0ms); }
@keyframes reveal { to { opacity: 1; transform: none; } }

@media (max-width: 760px) {
  body { background-attachment: scroll !important; }
  .container, .wrap { width: min(100% - 20px, 1180px) !important; padding-top: 12px !important; }
  .app-bar { min-height: 54px; margin-bottom: 10px; }
  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; }
  .brand-sub, .app-status span { display: none; }
  .composer-head { display: block; }
  .utility-rail { justify-content: flex-start !important; margin: 14px 0 0; }
  .form-row { display: block !important; }
  .form-side, html[dir=rtl] .form-side { border: 0; padding: 14px 0 0; }
  .actions { gap: 7px !important; }
  .actions button { flex: 1 1 130px; }
  .header { display: block !important; }
  .controls { margin-top: 16px; }
  .controls > * { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }
  body { background-position: center !important; }
}