:root {
  color-scheme: light;
  --background: #f2f3f9;
  --surface: #fff;
  --ink: #231f45;
  --muted: #625f7a;
  --border: #c6c7d7;
  --hairline: #d8daea;
  --accent: #493390;
  --accent-hover: #3c297c;
  --focus: #6747bf;
  --gutter: max(16px, calc((100vw - 1040px) / 2));
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 0.2em; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.72; }
:where(button, a, input, textarea, summary):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}

.header-inner {
  min-height: 49px;
  margin-inline: var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.brand {
  font-size: 1.3rem;
  line-height: 1.25;
  letter-spacing: -0.04em;
  font-weight: 760;
}

.text-button {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 590;
}

.text-button:hover { text-decoration: underline; }

.page {
  margin-inline: var(--gutter);
  padding: 25px 0 max(42px, env(safe-area-inset-bottom));
}

h1 {
  margin: 0 0 18px;
  font-weight: 750;
  font-size: clamp(1.66rem, 6vw, 2.5rem);
  letter-spacing: -0.045em;
  line-height: 1.15;
}

h2, label, legend {
  display: block;
  margin: 0 0 7px;
  padding: 0;
  font-size: 1rem;
  line-height: 1.28;
  font-weight: 620;
}

.editor-grid, .note-form { display: grid; gap: 17px; }
.editor-grid > * { min-width: 0; }
.widget-card {
  --widget-top: #25204f;
  --widget-bottom: #44368a;
  --widget-body: #e4ddff;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 6px;
  min-height: 129px;
  border-radius: 20px;
  padding: 19px 22px;
  background: linear-gradient(133deg, var(--widget-top), var(--widget-bottom));
  color: #fff;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.widget-card[data-theme='green'] { --widget-top: #16372e; --widget-bottom: #245747; --widget-body: #dcf5ea; }
.widget-card[data-theme='dark'] { --widget-top: #20232d; --widget-bottom: #3a4051; --widget-body: #e7eaf5; }
.widget-title, .widget-body {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.widget-title {
  font-size: 1.5rem;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.025em;
  -webkit-line-clamp: 1;
}

.widget-body {
  font-size: 1rem;
  line-height: 1.3;
  color: var(--widget-body);
  white-space: pre-wrap;
  -webkit-line-clamp: 4;
}

:where(input:not([type='radio']), textarea) {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}

input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { min-height: 88px; resize: vertical; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.themes { display: flex; flex-wrap: wrap; gap: 8px; }
.theme { position: relative; margin: 0; font-size: 0.875rem; }
.theme > input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.theme > span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  font-weight: 520;
  cursor: pointer;
}

.theme > span::before {
  content: '';
  width: 15px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #6c45b8;
}
.theme[data-theme='green'] > span::before { background: #347359; }
.theme[data-theme='dark'] > span::before { background: #33384c; }
.theme > input:checked + span { border-color: var(--focus); background: #eae2ff; }
.theme > input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 3px; }

.primary, .secondary {
  min-height: 45px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 680;
  padding: 8px 14px;
}
.primary { width: 100%; background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-hover); }
.secondary { background: var(--surface); border-color: var(--border); color: var(--accent); }
.secondary:hover { border-color: var(--focus); }
.note-form .primary { margin-top: 5px; }
.feedback { color: #215942; font-size: 0.94rem; }
.feedback[data-error='true'] { color: #a02b45; }

.connection { margin-top: 20px; border-top: 1px solid var(--hairline); }
.connection summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 4px 13px 0;
  list-style: none;
  font-size: 1.06rem;
  font-weight: 620;
  cursor: pointer;
}
.connection summary::-webkit-details-marker { display: none; }
.connection summary::after {
  content: '';
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
}
.connection[open] summary::after { transform: translateY(3px) rotate(225deg); }
.connection-content { color: var(--muted); max-width: 45rem; }
.connection-content ol { margin: 0 0 16px; padding-left: 21px; }
.connection-content li + li { margin-top: 13px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin: 8px 0; }
.text-link { display: inline-flex; align-items: center; min-height: 44px; }
.connection-content .copy-field { font-family: ui-monospace, monospace; font-size: 1rem; }
.hint { margin-top: 5px; color: var(--muted); font-size: 0.875rem; }
.linked { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.access { max-width: 410px; margin: 24px auto 0; }
.access form { display: grid; }
#access-hint { margin-bottom: 15px; color: var(--muted); }
.access .primary, .access .feedback { margin-top: 14px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  margin: -1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

@media (min-width: 690px) {
  :root { --gutter: max(32px, calc((100vw - 960px) / 2)); }
  .header-inner { min-height: 58px; }
  .page { padding-top: 38px; }
  h1 { margin-bottom: 28px; }
  .editor-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 34px; }
  .widget-card { min-height: 155px; padding: 22px; }
  .connection { margin-top: 30px; }
}
