:root {
  --bg: #f4f7ff;
  --surface: #ffffff;
  --surface-2: #f1f4fb;
  --text: #1f2533;
  --muted: #6b7488;
  --primary: #6c5ce7;
  --primary-hover: #5a49d6;
  --danger: #ff5a78;
  --border: #e6e9f2;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(76, 88, 130, 0.10);
  --shadow-sm: 0 2px 8px rgba(76, 88, 130, 0.08);
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must override author display rules (e.g. .view). */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  min-height: 100vh;
  background: var(--bg);
  background-image: radial-gradient(
      1200px 600px at 50% -200px,
      #e7ecff 0%,
      rgba(231, 236, 255, 0) 70%
    ),
    linear-gradient(180deg, #f7f9ff 0%, var(--bg) 100%);
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
}

.logo {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--primary), #00b4d8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero {
  text-align: center;
  padding: 16px 0 4px;
}

.hero-emoji {
  font-size: 2.6rem;
  line-height: 1;
  margin-bottom: 8px;
}

.hero-title {
  margin: 0 0 4px;
  font-size: 1.6rem;
  font-weight: 700;
}

.tagline {
  color: var(--muted);
  text-align: center;
  margin: 8px 0 4px;
}

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: -6px 0 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
}

label {
  font-size: 0.9rem;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
}

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

#room-key-input {
  letter-spacing: 6px;
  font-size: 1.4rem;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(108, 92, 231, 0.35);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  min-height: 40px;
  padding: 0 12px;
}

.btn-ghost:hover {
  color: var(--text);
}

#copy-key-btn {
  background: var(--surface-2);
  color: var(--primary);
  font-weight: 600;
}

#copy-key-btn:hover {
  background: #e7e9f6;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider span {
  padding: 0 12px;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0;
  min-height: 1.2em;
}

/* Room header */
.room-header {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.room-key-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.room-key-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.room-key {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 6px;
}

.back {
  font-size: 1.3rem;
}

/* Room expiry banner */
.room-expiry {
  margin: 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Note form */
.note-form-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.note-form-row select {
  flex: 1;
}

.note-form-row .btn {
  flex: 0 0 auto;
}

/* Notes list */
.notes-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.note-text {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 64px 8px 0;
}

.note-text a {
  color: var(--primary);
  text-decoration: underline;
  word-break: break-all;
}

.note-meta {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.note-copy,
.note-delete {
  position: absolute;
  top: 8px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 8px;
  line-height: 1;
}

.note-delete {
  right: 8px;
}

.note-copy {
  right: 44px;
}

.note-delete:hover {
  color: var(--danger);
  background: var(--surface-2);
}

.note-copy:hover {
  color: var(--primary);
  background: var(--surface-2);
}

.note-copy.copied {
  color: var(--primary);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 24px 0;
}

@media (max-width: 420px) {
  .room-key {
    font-size: 1.3rem;
    letter-spacing: 4px;
  }
}
