/* ============================================================
   QuRi - Style Sheet
   ============================================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", Meiryo, sans-serif;
  background: #fafafa;
  color: #222;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
.header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
}

.header__logo {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #111;
}

.header__logo-img {
  height: 200px;
  width: auto;
  display: block;
  margin: 0 auto;
}


.header__tagline {
  font-size: 0.85rem;
  color: #888;
  margin-top: 0.25rem;
}

/* --- Main Tabs --- */
.tabs {
  display: flex;
  justify-content: center;
  background: #fff;
  border-bottom: 2px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.tabs__btn {
  flex: 1;
  max-width: 240px;
  padding: 0.85rem 1rem;
  border: none;
  background: transparent;
  font-size: 1rem;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.tabs__btn:hover {
  color: #444;
}

.tabs__btn--active {
  color: #111;
}

.tabs__btn--active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: #333;
}

/* --- Tab Panels --- */
.tab-panel {
  display: none;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.tab-panel--active {
  display: block;
}

main {
  flex: 1;
}

/* --- Functional Area / Info Area --- */
.func-area {
  margin-bottom: 2.5rem;
}

.info-area {
  border-top: 1px solid #e0e0e0;
  padding-top: 2rem;
  color: #555;
  font-size: 0.9rem;
}

.info-area h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: #333;
}

.info-area h3 {
  font-size: 0.95rem;
  margin: 1.25rem 0 0.5rem;
  color: #333;
}

.info-area ol {
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.info-area li {
  margin-bottom: 0.35rem;
}

.info-area p {
  margin-bottom: 0.5rem;
}

/* --- Form Elements --- */
.label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 0.35rem;
}

.textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  background: #fff;
  transition: border-color 0.2s;
}

.textarea:focus {
  outline: none;
  border-color: #555;
}

.select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s;
}

.select:focus {
  outline: none;
  border-color: #555;
}

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  text-align: center;
}

.btn:active {
  opacity: 0.8;
}

.btn--primary {
  background: #333;
  color: #fff;
}

.btn--primary:hover {
  background: #111;
}

.btn--secondary {
  background: #e8e8e8;
  color: #333;
}

.btn--secondary:hover {
  background: #d5d5d5;
}

/* --- Generate Tab Specific --- */
.generate-input {
  margin-bottom: 1rem;
}

.generate-options {
  margin-bottom: 1.25rem;
}

#btn-generate {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
}

/* --- QR Preview --- */
.qr-preview {
  margin-top: 1.5rem;
  text-align: center;
}

.qr-preview canvas {
  max-width: 280px;
  width: 100%;
  height: auto;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background-image:
    linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
    linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
    linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.qr-download-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1rem;
}

.qr-download-buttons .btn {
  flex: 1;
  max-width: 200px;
}

/* --- Error Messages --- */
.error-msg {
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.85rem;
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  margin-top: 0.75rem;
  border: 1px solid #fecaca;
}

/* --- Sub Tabs (Read) --- */
.subtabs {
  display: flex;
  gap: 2px;
  background: #e8e8e8;
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 1.25rem;
}

.subtabs__btn {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: #777;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.subtabs__btn--active {
  background: #fff;
  color: #111;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.subtab-panel {
  display: none;
}

.subtab-panel--active {
  display: block;
}

/* --- Camera --- */
.camera-controls {
  margin-bottom: 1rem;
}

.camera-viewport {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
  position: relative;
}

.camera-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#btn-start-camera,
#btn-stop-camera {
  width: 100%;
}

#btn-stop-camera {
  margin-top: 0.5rem;
}

/* --- Image Upload --- */
.upload-label {
  display: block;
  text-align: center;
  cursor: pointer;
}

#image-preview-area {
  margin-top: 1rem;
  text-align: center;
}

#image-preview {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

/* --- Read Result --- */
.read-result {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}

.read-result h3 {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 0.75rem;
}

.read-result__content {
  background: #f7f7f7;
  border-radius: 6px;
  padding: 0.85rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}

.result-text {
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  line-height: 1.6;
  color: #222;
}

.read-result__actions {
  display: flex;
  gap: 0.75rem;
}

.read-result__actions .btn {
  flex: 1;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 0.6rem 1.5rem;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast--visible {
  opacity: 1;
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.8rem;
  color: #aaa;
  border-top: 1px solid #e0e0e0;
  background: #fff;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .header {
    padding: 1.5rem 1rem 0.75rem;
  }

  .header__logo {
    font-size: 1.6rem;
  }

  .qr-download-buttons {
    flex-direction: column;
    align-items: center;
  }

  .qr-download-buttons .btn {
    max-width: 100%;
    width: 100%;
  }
}
