:root {
  --bg: #f4f8fc;
  --card: #ffffff;
  --line: #d8e1ea;
  --text: #1b2a39;
  --muted: #5d6e7f;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --error: #b42318;
  --success: #0b7a43;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #dff4ff, transparent 28rem), var(--bg);
}

.shell {
  width: min(980px, calc(100% - 2rem));
  margin: 2rem auto 3rem;
  display: grid;
  gap: 1rem;
}

.hero {
  background: linear-gradient(145deg, #12334c, #1b4d68);
  color: #f5fbff;
  border-radius: 14px;
  padding: 1.5rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}

.hero h1 {
  margin: 0.45rem 0 0;
  font-size: clamp(1.5rem, 3.5vw, 2.3rem);
}

.summary {
  margin: 0.9rem 0 0;
  max-width: 56rem;
  line-height: 1.55;
}

.hero-nav {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.hero-nav a {
  display: inline-block;
  text-decoration: none;
  color: #e8f4ff;
  border: 1px solid rgba(232, 244, 255, 0.45);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.88rem;
}

.hero-nav a:hover {
  background: rgba(232, 244, 255, 0.15);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.2rem;
}

.card h2 {
  margin: 0;
  font-size: 1.15rem;
}

.muted {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.auth-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.auth-actions,
.result-actions {
  display: flex;
  gap: 0.7rem;
}

.save-form {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.8rem;
}

label {
  font-weight: 600;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.72rem 0.82rem;
}

textarea {
  margin-top: 0.8rem;
  min-height: 18rem;
  resize: vertical;
  font-family: Consolas, Monaco, 'Courier New', monospace;
  line-height: 1.45;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.62rem 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

#connect-button,
#save-button {
  background: var(--primary);
  color: var(--primary-ink);
}

.ghost {
  background: #eef4f9;
  color: var(--text);
  border: 1px solid var(--line);
}

.status {
  margin: 0.8rem 0 0;
  color: var(--muted);
}

.status[data-state='loading'] {
  color: #175cd3;
}

.status[data-state='error'] {
  color: var(--error);
}

.status[data-state='success'] {
  color: var(--success);
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.notes-list {
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.notes-list:empty {
  display: none;
}

.notes-list li {
  border-top: 1px solid var(--line);
  padding: 0.78rem 0.9rem;
  background: #fbfdff;
}

.notes-list li:first-child {
  border-top: 0;
}

.note-name {
  margin: 0;
  font-weight: 600;
}

.note-row {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
}

.note-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.note-btn {
  background: #eef4f9;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.36rem 0.72rem;
  font-weight: 600;
  font-size: 0.84rem;
}

.note-btn-icon {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.note-btn-icon.note-btn-edit::before {
  content: '';
  width: 1rem;
  height: 1rem;
  display: block;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b5dc9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.note-btn-danger {
  color: #b42318;
  background: #fff1f1;
  border-color: #f7c3c0;
}

.note-btn-icon.note-btn-danger::before {
  content: '';
  width: 1rem;
  height: 1rem;
  display: block;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b42318' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M8 6V4h8v2'/%3E%3Cpath d='M19 6l-1 14H6L5 6'/%3E%3Cpath d='M10 11v6'/%3E%3Cpath d='M14 11v6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.note-meta {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.note-link {
  margin-top: 0.45rem;
  word-break: break-all;
}

.note-link a {
  color: #0b5dc9;
}

.note-panel {
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem;
  background: #ffffff;
}

.note-panel[hidden] {
  display: none;
}

.note-rendered {
  color: var(--text);
  line-height: 1.55;
}

.note-rendered h1,
.note-rendered h2,
.note-rendered h3,
.note-rendered h4 {
  margin: 1rem 0 0.45rem;
  line-height: 1.25;
}

.note-rendered p {
  margin: 0.5rem 0;
}

.note-rendered ul {
  margin: 0.55rem 0;
  padding-left: 1.15rem;
}

.note-rendered pre {
  margin: 0.7rem 0;
  padding: 0.7rem;
  border-radius: 8px;
  background: #f3f7fb;
  border: 1px solid var(--line);
  overflow-x: auto;
  font-family: Consolas, Monaco, 'Courier New', monospace;
}

.note-rendered .note-media,
.note-rendered .note-video {
  display: block;
  width: min(100%, 40rem);
  max-width: 100%;
  margin-top: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfe;
}

.note-frontmatter {
  margin-bottom: 0.8rem;
}

.note-frontmatter summary {
  cursor: pointer;
  color: #0b5dc9;
}

.note-editor {
  display: grid;
  gap: 0.6rem;
}

.note-editor textarea {
  margin-top: 0;
  min-height: 16rem;
}

.note-editor-actions {
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 760px) {
  .auth-card,
  .result-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-actions,
  .result-actions {
    width: 100%;
  }

  button {
    flex: 1;
  }

  .note-row {
    flex-direction: column;
  }
}
